This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func test() (x int) { | |
| defer func() { | |
| x++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "reflect" | |
| "unsafe" | |
| ) | |
| func main() { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "net" | |
| "time" | |
| ) | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "golang.org/x/tour/tree" | |
| ) | |
| // Walk walks the tree t sending all values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type User struct { | |
| Name string | |
| Email string | |
| Notifier UserNotifier | |
| } | |
| type UserNotifier interface { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // by: throw_away_stacy on reddit | |
| // and yes I do birthday parties too | |
| const WebSocket = require('websocket').w3cwebsocket; | |
| const users = require('./users.json'); | |
| const Q = require('q'); | |
| const superagent = require('superagent'); | |
| const _ = require('highland'); | |
| const getPixels = require('get-pixels'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| // A simple demo implementation of a Redis job queue in Go inspired on http://stackoverflow.com/a/34754632 | |
| // You'll need to get redis driver package in terminal with: go get -u gopkg.in/redis.v5 | |
| // Once it is running, Redis should look like: http://i.imgur.com/P4XlwlP.png | |
| // Terminal should look like: http://i.imgur.com/AS2IIbP.png | |
| // I have 4 days of Go programming experience, have mercy. | |
| import ( | |
| "fmt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func main() { | |
| isPalindrome(121) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Joi = require('joi'); | |
| const userSchema = Joi.object().keys({ | |
| did: Joi.string().required().error(new Error('Please provide Device token')), | |
| sName: Joi.string().required().error(new Error('Please provide user name')), | |
| sCountry: Joi.string().error(new Error('Please provide user country')), | |
| sImage: Joi.string(), | |
| sGameType: Joi.any() | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // setTimeout = function setTimeout() { | |
| // return console.log('Not Implemented'); | |
| // }; | |
| const first = () => console.log('first'); | |
| const second = () => console.log('second'); | |
| const runFirst = () => { process.nextTick(()=> first());}; | |
| const runSecond = () => { setImmediate(()=> second())}; | |
| runSecond(); | |
| runFirst(); | |
| console.log('now'); |