Skip to content

Instantly share code, notes, and snippets.

View ryanhanwu's full-sized avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@ryanhanwu
ryanhanwu / parsekeyword.js
Last active October 25, 2018 13:50
Parse Double Quote #Search
module.exports= function parseKeywords(req, res, next){
const { q } = res.locals
//extract double quote terms
const re = /"(.*?)"/g
const phrases = []
let current
while ((current = re.exec(q))) {
phrases.push(current.pop())
}
//replace -_. with space for matches
@ryanhanwu
ryanhanwu / docker_est.sh
Last active January 16, 2020 18:55
Set #docker timezone to EST
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y tzdata
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
@ryanhanwu
ryanhanwu / the-scratch.conf
Created May 4, 2018 14:10 — forked from korczis/the-scratch.conf
Nginx Node.js Proxy with caching, websockets, gzip
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
# the IP(s) on which your node server is running. I chose port 3000.
upstream app_the_scratch {
server 127.0.0.1:3000 weight=1 fail_timeout=60s;
}
# the nginx server instance
server {
@ryanhanwu
ryanhanwu / dynamoScanPromise.js
Created April 26, 2017 17:15
A short snippet for scanning AWS DynamoDB table with AWS SDK and Promise
var params = {
TableName: 'MYTABLE',
FilterExpression: 'contains (myKey , :query)',
ExpressionAttributeValues: {
':query': query
}
}
var dynamoScan = new Promise(function(resolve, reject) {
var results = []
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@ryanhanwu
ryanhanwu / The Technical Interview Cheat Sheet.md
Created January 29, 2017 03:13 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@ryanhanwu
ryanhanwu / tmux-cheatsheet.markdown
Created January 12, 2017 02:23 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ryanhanwu
ryanhanwu / gist:8a8013c1f3d65a178dc5bb070e3b8c0b
Created May 10, 2016 02:50 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@ryanhanwu
ryanhanwu / gist:e99fe81156e5eede72d909b71a33addb
Created May 9, 2016 14:01 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@ryanhanwu
ryanhanwu / git-aliases.md
Created March 21, 2016 18:52 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc