Skip to content

Instantly share code, notes, and snippets.

View krishna2nd's full-sized avatar
🎯
Focusing

Krishna krishna2nd

🎯
Focusing
View GitHub Profile
@krishna2nd
krishna2nd / gist:4c177813db8be918c2003000c2d76085
Created November 5, 2017 10:59 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@krishna2nd
krishna2nd / gist:494cd5618a32047465467c011f84ffd8
Created November 5, 2017 10:59 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@krishna2nd
krishna2nd / Go Select Implementation.md
Last active October 25, 2017 02:45
Go Select Implementation

Go Select Implementation

There are several steps to execute a select block:

  1. Evaluate all involved channels and values to be potentially sent, from top to bottom and left to right.
  2. Randomise the case orders for polling (the default branch is treated as a special case). The corresponding channels of the orders may be duplicate. The default branch is always put at the last position.
  3. sort all involved channels to avoid deadlock in the next step. No duplicate channels are in the first N channels of the sorted result, where N is the number of involved channels in the select block. Below, the sorted lock orders mean the the first N ones.
  4. lock all involved channels by the sorted lock orders in last step.
  5. poll each cases in the select block by the randomised case orders:
@krishna2nd
krishna2nd / channels.go
Created October 25, 2017 01:32
Go dual channels
package main
import (
"fmt"
)
func printch(ch1, ch2, q chan int) {
for {
select {
case x := <-ch1:
@krishna2nd
krishna2nd / wg_routines.go
Created October 23, 2017 15:06
Wait for group + routines Golang
package main
import (
"fmt"
"sync"
)
func main() {
var wg = sync.WaitGroup{}
for v := range []int{1, 2, 3, 4, 5, 6} {
package main;
import (
"fmt"
)
func main() {
var val = []int{ 1,2 ,3 ,4 ,115 ,6 ,17 ,8 ,9 };
var l1, l2 int = val[0], 0;
for _, v := range val {
if (l1 < v) {
// Parentheses pairing ({}[]()<>)
//
package main;
import (
"fmt"
"strings"
)
func main() {
fmt.Println(stringMatch("{[(])}"));

ECMAScript 5 Strict Mode, JSON, and More Previously I analyzed ECMAScript 5’s Object and Property system. This is a huge new aspect of the language and deserved its special consideration.

There are a number of other new features and APIs that need attention, as well. The largest of which are Strict Mode and native JSON support.

Strict Mode Strict Mode is a new feature in ECMAScript 5 that allows you to place a program, or a function, in a “strict” operating context. This strict context prevents certain actions from being taken and throws more exceptions (generally providing the user with more information and a tapered-down coding experience).

Since ECMAScript 5 is backwards-compatible with ECMAScript 3, all of the “features” that were in ECMAScript 3 that were “deprecated” are just disabled (or throw errors) in strict mode, instead.

let target = {
foo: "Welcome, foo"
}
let proxy = new Proxy(target, {
get (receiver, name) {
// get value from target if proprty exists else some logic from proxy
return name in receiver ? receiver[name] : `Hello, ${name}`
},
// set value to target by adding new property
set (receiver, name, value) {
const out = {
userSucc: {
succ: true,
t: 200,
value: {
name: "krishna",
age: 20
}
},
userError: {