Skip to content

Instantly share code, notes, and snippets.

View manjeettahkur's full-sized avatar

Manjeet Singh manjeettahkur

View GitHub Profile
package main
import (
"fmt"
)
func test() (x int) {
defer func() {
x++
package main
import (
"fmt"
"reflect"
"unsafe"
)
func main() {
package main
import (
"context"
"fmt"
"net"
"time"
)
func main() {
package main
import (
"fmt"
"math/rand"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
@manjeettahkur
manjeettahkur / main.go
Created May 8, 2020 07:13
Interface Example
package main
import "fmt"
type User struct {
Name string
Email string
Notifier UserNotifier
}
type UserNotifier interface {
// 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');
@manjeettahkur
manjeettahkur / redisjobqueue.go
Created March 19, 2020 06:28 — forked from brunocassol/redisjobqueue.go
A simple demo implementation of a Redis job queue in Go inspired on http://stackoverflow.com/a/34754632
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"
@manjeettahkur
manjeettahkur / palindrome.go
Created January 16, 2020 14:35
check is number is palindrome or not
package main
import (
"fmt"
"math"
)
func main() {
isPalindrome(121)
}
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()
});
@manjeettahkur
manjeettahkur / async-con.js
Last active May 4, 2019 13:19
how process.nextTick and setImmediate works i nodejs
// 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');