This file contains 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" | |
"errors" | |
"fmt" | |
"time" | |
) | |
/* |
This file contains 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
// when you get a list of objects to resolve, you create a slice of resolvers for each | |
// element in the list of objects. But be careful how you structure your loops because | |
// there are a log of pointers to pointers etc | |
func (*rootResolver) TeamsByNickname(args struct{ Nickname string }) *[]*teamResolver { | |
// assume teams = slice of objects from a database | |
// create a list of resolvers : the right way | |
// this is ok because it gives a pointer to elements of the slice |
This file contains 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
# base linux with version | |
FROM debian:10.2 | |
# apt setup | |
RUN apt-get update | |
# unversioned tools | |
RUN apt-get install -y git | |
RUN apt-get install -y curl | |
RUN apt-get install -y bash-completion |
This file contains 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
/* | |
build with visual studio 2019 (2017/15 should work too), x64 debug build | |
*/ | |
#include <Windows.h> | |
#include <cstdio> | |
#include <cstdint> | |
#include <cstring> | |
#include <cassert> | |
struct Baton { |
This file contains 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 bcrypt = require("bcrypt"); | |
// use this library in case your version of node doesn't support Promise | |
// const Promise = require("promise"); | |
let password = "hello"; | |
let stored_hash = ""; | |
// first generate a random salt | |
function genSalt(password) { | |
return new Promise((resolve, reject) => { |
This file contains 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
#include <cstdio> | |
#include <cstdlib> | |
#include <cstring> | |
struct X { | |
private: | |
size_t m_len; | |
char *m_data; | |
public: | |
X() : m_len(0),m_data(nullptr) { |
This file contains 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
SQL VS NOSQL == CAP vs ACID | |
NOSQL: | |
CAP : consistency, availability,partition tolerance (Brewer) | |
distributed | |
horizontal scale | |
unstructured | |
use for maybe data | |
asynchronous | |
transactions might seem to work but fail later |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
</head> | |
<body> | |
<script> | |
$.get("http://cdn.jsdelivr.net/ramda/0.18.0/ramda.min.js", |
This file contains 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
"use strict"; | |
var util = require('util'); | |
var clone = require('clone'); | |
function inspect(o) { | |
console.log(util.inspect(o)); | |
} | |
function clone1(o) { | |
var n = {}; |
This file contains 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
"use strict"; | |
// ================================================= | |
// a common question that pops up is | |
// 'why do my async functions use the final value of my loop variable instead of the one they are called with'? | |
// its because they refer directly to the loop variable and its last value | |
// the solutions are various ways to bind the loop variable in a new scope | |
// | |
// this gist shows different ways to handle a loop that spawns an async function that depends on the loop index | |
// ================================================= |
NewerOlder