Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Code



  Turn browser into notepad with one line of code

This is the code shared by Jose on codewall. When you type data:text/html,   into the address bar of the browser and press enter, the browser will turn into a notepad which you can edit. Why it works? This uses Data URI’s format and it tells the browser to render HTML. But contenteditable is a property of HTML5, so this can only work in the web browser which supports this property. Here are some interesting contents. Some people make some changes to the code encouraged by the ide...

   HTML5, Browser editor     2013-01-30 04:20:54

  Bing now supports code search

In programmer's daily life, much time is spent on searching Google or StackOverflow for code snippets which can help them understand how the code works. Now there is one more option. Microsoft's Bing now adds a new feature which support code snippet search. With this new feature, you can search code snippet and execute them directly within the search results. For example, if you type "quick sort java", you will see below search result : This feature now supports a few popular programming langua...

   BING,CODE SEARCH,HACKERRANK     2016-04-09 02:49:25

  Error handling style in C

Following are three error handling styles in C.Which one you like the most? Or you don't like any one?1. /* Problem : Not enough. Easy to be wrong */int foo(int bar){        int return_value = 0;        int doing_okay = 1;        doing_okay = do_something( bar );        if (doing_okay)        { ...

   C,Error handling style,Goto,Nested if     2012-04-24 06:51:00

  2013 Google Code Jam is around the corner

According to Google Code Jam, the registration time of Google Code Jam 2013 will start on 12th March, and the deadline for registration will be 14th April 00:00UTC. This year the champion will get $15,000. Besides the prize and title, the champion will be enrolled in the qualification round in 2014 directly. Since 2003, Google Code Jam attracted many professional and students to solve the hardest algorithm problems in the world. Last year, there were over 35000 programmers participated in this c...

   Google,Code Jam 2013     2013-03-13 05:48:24

  A small trick on using console.log to print data in JavaScript

When debugging JavaScript application, one may frequently use console.log to print data so that it is easy to debug when issue occurs and also helps on understand the data flow. The common way of printing a variable would be something like.  let user = { name: "test" }; console.log(user); In this case it will print: { name: 'test' } This is OK when there is no much logging or the program is not complicated. But it becomes difficult to debug if there are lots of variables to be printed ...

   JAVASCRIPT,CONSOLE.LOG,DEBUGGING     2019-09-03 10:24:24

  What is the use of empty struct in GoLang

In Go, an empty struct struct{} is a struct with no fields that may appear to be of little use, but in reality, it can be useful in certain situations and become a simple and efficient solution in code. As a semaphore or lock Because the empty struct has no fields, it can be conveniently used to implement some concurrency control functions, such as mutex locks, read-write locks. We can use chan struct{} to implement an unbuffered channel for controlling concurrent access. package main import ( ...

   GOLANG,EMPTY STRUCT     2024-04-05 23:54:03

  A simple tutorial about CSS flex property

CSS Flexbox is a layout module that makes it easier to create flexible and responsive layouts in CSS. It provides a simple and powerful way to align elements within a container and distribute space between them. To use flexbox, you need to set the display property of an element to "flex". You can do this by adding the following rule to your CSS: .container { display: flex; } The flex container will now have two main axes: the main axis and the cross axis. By default, the main axis runs horizo...

   JUSTIFY-CONTENT,FLEX,CSS     2022-12-25 06:44:34

  Why you should be careful about optimizations

In one of my current javascript projects, I have to deal with 3D voxel coordinates. And, sometimes, I have floating points coordinates which must be converted to integers in order to convert them into proper array index. Javascript is a wonderful language, really. However, implementations are sometimes weird, and the way to do something can sometimes have very huge impacts on the performances. Worse, sometimes the classical way is more expensive than the tricky one. So, some peo...

   JavaScript,Bitwise,Floor,Trick,Optimization     2012-05-02 11:29:20

  Introduction to GoLang generics and advanced usage

Generics in Go allow you to write code that can work with multiple types of data, without having to write separate versions of the code for each type. This can make your code more flexible and easier to maintain, as you only need to write and test the code once, rather than maintaining multiple versions. To use generics in Go, you first need to define a type parameter, which is a placeholder for the type that the code will work with. For example, you might define a type parameter called "T" like...

   GOLANG,GENERICS     2022-12-17 05:12:21

  JavaScript: Passing by Value or by Reference

In JavaScript, we have functions and we have arguments that we pass into those functions. But how JavaScript handles what you’re passing in is not always clear. When you start getting into object-oriented development, you may find yourself perplexed over why you have access to values sometimes but not other times. When passing in a primitive type variable like a string or a number, the value is passed in by value. This means that any changes to that variable while in the function are com...

   JavaScript,Function,Pass by reference,Pa     2011-07-28 11:05:25