Skip to content

Instantly share code, notes, and snippets.

Will Stern willrstern

Block or report user

Report or block willrstern

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mysql2sqlite.sh
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@willrstern
willrstern / node-ubuntu-upstart-service.md
Last active Sep 10, 2019
Run Node.js App as Ubuntu Upstart Service
View node-ubuntu-upstart-service.md

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@willrstern
willrstern / gist:af3a3308fc5864cf48f8
Last active Feb 13, 2018
JAVASCRIPT AND ASYNC OPERATIONS 2: Parallel Sequence
View gist:af3a3308fc5864cf48f8

##Example Task: Make 2 parallel (simultaneous) async calls, then one async call when they've resolved##

##The Good Way: Promises##

//with bluebird library
var parallelCalls = [
  getUrl('/api/profile'),
  getUrl('/api/accounts')
];
//spread is like .then(), except it apply()s the array of responses as individual arguments
@willrstern
willrstern / gist:a46567b4f489c4c30f29
Last active Feb 13, 2018
JAVASCRIPT AND ASYNC OPERATIONS
View gist:a46567b4f489c4c30f29

##The Good, The Bad, & The Ugly Ways of handling Async Operations With Javascript## #####Callbacks < Promises < Generators#####


###An Example: 5 in-sequence Async Operations### (also see parallel-sequence example: https://gist.github.com/willrstern/af3a3308fc5864cf48f8)
###The Ugly Way: Callbacks### After each function takes place, handle any errors & do the next thing - It's easy to walk through the code and understand what's going on...but it's ugly as sin
You can’t perform that action at this time.