Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Tri Vuong trivektor

🏠
Working from home
View GitHub Profile
@trivektor
trivektor / values_pointers.go
Created Jun 26, 2021 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
View values_pointers.go
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@trivektor
trivektor / twitter_streaming.js
Created Sep 15, 2020 — forked from ryanmcgrath/twitter_streaming.js
Access the Twitter Streaming API with ease (Node.js).
View twitter_streaming.js
var util = require('util'),
http = require('http'),
events = require('events');
var Twitter = function(opts) {
this.username = opts.username;
this.password = opts.password;
this.track = opts.track;
this.data = '';
};
@trivektor
trivektor / bootstrap-memo.md
Created Feb 25, 2018 — forked from yalab/bootstrap-memo.md
rails5 + webpacker + bootstrap
View bootstrap-memo.md
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add bootstrap@4.0.0-beta jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@trivektor
trivektor / installing_cassandra.md
Created Jan 12, 2018 — forked from hkhamm/installing_cassandra.md
Installing Cassandra on Mac OS X
View installing_cassandra.md

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@trivektor
trivektor / latency.txt
Created Nov 6, 2017 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
View gist:2aec44e2c44c5f3f7ffe928c5eacb0dc
if (!_isEmpty(executedCode)) {
// https://nodejs.org/api/vm.html
const vm = require('vm');
const babel = require('babel-standalone');
const sandbox = {
project,
projectId,
require: require,
};
View gist:6fd966842751df141f025a2361a6fb34
1/ Compare file between 2 different branches
git diff mybranch master -- myfile.cs
@trivektor
trivektor / asyncloops.js
Created Jan 10, 2017 — forked from lukehoban/asyncloops.js
Async/await and parallel loops
View asyncloops.js
// ES6 w/ Promises
// Note: From a React starter template - see https://t.co/wkStq8y3I5
function fetchData(routes, params) {
let data = {};
return Promise.all(routes
.filter(route => route.handler.fetchData)
.map(route => {
return route.handler.fetchData(params).then(resp => {
data[route.name] = resp;
@trivektor
trivektor / states_hash.json
Last active Jan 5, 2017 — forked from mshafrir/states_hash.json
US states in JSON form
View states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
"FL": "Florida",