Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nemoDreamer's full-sized avatar
🔎
Working at SyncSketch.

Philip Blyth nemoDreamer

🔎
Working at SyncSketch.
View GitHub Profile
@bdougherty
bdougherty / README.md
Last active April 1, 2022 05:54
Play the Benny Hill theme song while installing npm modules

Add the function somewhere to your dotfiles. Works better if you npm install -g benny-hill first.

@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@takano32
takano32 / LGTM
Created June 23, 2015 10:03
LGTM
:pizza::cloud::cloud::cloud::cloud::cloud::cloud::cloud::cloud::pizza::pizza::pizza::pizza::pizza::cloud::cloud::pizza::pizza::pizza::pizza::pizza::pizza::pizza::cloud::pizza::cloud::cloud::cloud::cloud::cloud::pizza::cloud:
:pizza::cloud::cloud::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::pizza::pizza::cloud::cloud::cloud::pizza::pizza::cloud:
:pizza::cloud::cloud::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::cloud::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::pizza::cloud::pizza::cloud::pizza::cloud::pizza::cloud:
:pizza::cloud::cloud::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::pizza::pizza::pizza::pizza::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::pizza::cloud::cloud::pizza::cloud::cloud::pizza::cloud:
:pizza::cloud::cloud::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::cloud::cloud::cloud::pizza::cloud::cloud::clou
var reducePath = function (x, y, entryOffset, rangeOffset, entryRequiredWall, entryDisallowedWall) {
var rangeEntryRequiredDirections = [entryDisallowedWall, OppositeDirections[entryDisallowedWall]];
var rangeEntryDisallowedDirections = [entryRequiredWall, OppositeDirections[entryRequiredWall]];
var endDisallowedDirections = [OppositeDirections[entryRequiredWall], OppositeDirections[entryDisallowedWall]];
var endRequiredDirections = [entryRequiredWall, entryDisallowedWall];
var tile = tiles[x][y];
var color = tile.color;
var entry = tiles[x+entryOffset[0]][y+entryOffset[1]];
@nemoDreamer
nemoDreamer / 01_user_function.less
Last active August 29, 2015 14:06
User function approximation in server-side LESS (and a true greyscale "function")
@color: #f88;
/* LESS admits that their greyscale function doesn't respect relative lightness */
.bad_grayscale {
original-color: @color;
desaturated: desaturate(@color, 100%);
greyscaled: greyscale(@color); // synonymous
}
BEGIN{s,,=]=>%-{<-|}<&|`{,,y; -/:-@[-`{-};`-{/' -;,s,(.+)'$,$1*',&&s&&$_&gesex}
Challenge: deploy node-red to a heroku endpoint.
2013/12/27
First challenge -- you have to have red.js listen on process.env.PORT rather than 1880.
https://devcenter.heroku.com/articles/getting-started-with-nodejs
Second challenge -- web sockets -- node-red uses web sockets, so the server comes up and disconnects right away.
When you enable the lab:websockets it doesn't fix it out of the box.
https://blog.heroku.com/archives/2013/10/8/websockets-public-beta
@dtuite
dtuite / remove_trailing_whitespace.sh
Last active October 12, 2023 16:46
Recursively remove trailing whitepace from files.
# Remove trailing whitespace from files in the src directory.
# This is useful because (for example) trailing whitespace hinders Vim's
# paragraph movement.
# INFO: http://stackoverflow.com/a/4438318/574190
# INFO: http://stackoverflow.com/q/1583219/574190
# The directory under which we want to search for files.
ROOT_DIRECTORY="$1"
@slevithan
slevithan / xregexp-lookbehind2.js
Created April 14, 2012 21:06
Simulating lookbehind in JavaScript (take 2)
// Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp.
// Captures within lookbehind are not included in match results. Lazy
// repetition in lookbehind may lead to unexpected results.
(function (XRegExp) {
function prepareLb(lb) {
// Allow mode modifier before lookbehind
var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb);
return {