class Foo {
doSomething() {}
}
// Fastest
const Foo = () => {
// do something
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" | |
"fmt" | |
"strconv" | |
elastic "gopkg.in/olivere/elastic.v5" | |
) |
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
import re | |
import json | |
country_codes = [] | |
with open('./flags.css', 'r') as f: | |
lines = [x for x in f.readlines()] | |
for _, line in enumerate(lines): | |
out = re.match(r'\.flag\.flag-(.*)\s\{', line) | |
if out: |
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 ( | |
"encoding/json" | |
"fmt" | |
"strconv" | |
"strings" | |
"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
package main | |
import ( | |
"context" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
"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
// Concatenating strings directly | |
const firstName = 'john' | |
const lastName = 'doe' | |
// Bad, fullName(null, null) will return "null null" | |
function fullName (firstName, lastName) { | |
return firstName + ' ' + lastName | |
} |
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
// sample queries from github.api for specific requests | |
const searchUsersInMalaysia = 'https://api.github.com/search/users?q=location:malaysia' |
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 DBFactory = (name) => { | |
switch (name) { | |
case 'mongodb': return MongoDB() | |
case 'rethinkdb': return RethinkDB() | |
case 'redis': return Redis() | |
// For testing/mocking | |
case 'inmemory': return InMemory() | |
} | |
} |
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 ( | |
"encoding/json" | |
"fmt" | |
) | |
// This program demonstrates a simple conversion from one type to another | |
// Available from go1.8 onwards |
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 ( | |
// "fmt" | |
"log" | |
"time" | |
) | |
func delay100() bool { | |
time.Sleep(1 * time.Second) |