Skip to content

Instantly share code, notes, and snippets.

Nicholas Kramer namklabs

Block or report user

Report or block namklabs

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
@namklabs
namklabs / load-googlefonts-before-phaser.html
Last active May 21, 2018
Load Google Fonts before Phaser
View load-googlefonts-before-phaser.html
<head>
...
<link href="https://fonts.googleapis.com/css?family=VT323" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script>
WebFont.load( {
custom: {
families: [ 'VT323' ]
View observeDOM.js
// https://stackoverflow.com/a/14570614/448640
var observeDOM = (function(){
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
eventListenerSupported = window.addEventListener;
return function(obj, callback){
if( MutationObserver ){
// define a new observer
var obs = new MutationObserver(function(mutations, observer){
View imagelightbox.js
/*
By Osvaldas Valutis, www.osvaldas.info
https://osvaldas.info/image-lightbox-responsive-touch-friendly
Available for use under the MIT License
*/
;( function( $, window, document, undefined )
{
'use strict';
@namklabs
namklabs / 0_reuse_code.js
Created Oct 24, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@namklabs
namklabs / lorem-ipsum.sh
Last active Oct 31, 2018
bash lorem ipsum osx terminal
View lorem-ipsum.sh
function lorem(){
# Copy lorem ipsum to your clipboard in OS X
# usage:
# $ lorem <int> <htmlflag>
# where <int> is how many paragraphs of lorem ipsum you want, each separated by 2 newlines
# and <htmlflag> is anything, indicating you want each paragraph surrounded by <p></p>. Omit if you don't want this.
@namklabs
namklabs / batchDownload.js
Last active Jul 28, 2016
This function will download all of the files on a page. Use in dev console. Just tweak the selector to filter what types of links will be downloaded. Eliminates duplicate downloads. Requires jQuery. http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
View batchDownload.js
// requires jQuery
// tested only in Chrome console dev tools
// use jQuerify bookmarklet if your page doesn't have jQuery: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
function batchDownload( $jquery_collection_of_a_elements, buffer_ms, random_ms, timeonly_bool ){
if( $jquery_collection_of_a_elements.length < 1 ){
throw "Nothing to download! Empty jQuery collection.";
}
@namklabs
namklabs / rotateArrayRight.js
Created Apr 26, 2016
rotate a 2D (2 dimensional) array clockwise (right) by 90 degrees in JavaScript
View rotateArrayRight.js
function rotateArrayRight( arr ){
// rotates a 2D array 90 degrees to the right (clockwise)
var newarr = [];
for( var x = 0; x < arr[0].length; x++ ){
newarr[x] = [];
for( var y = arr.length - 1; y >= 0; y-- ){
newarr[x].push( arr[y][x] );
}
@namklabs
namklabs / terminus-search-replace.sh
Last active Apr 1, 2016 — forked from wpscholar/terminus-search-replace.sh
WP-CLI Search and Replace via Terminus (on Pantheon)
View terminus-search-replace.sh
terminus wp "search-replace 'find' 'replace' --dry-run" --site=mysite --env=dev|test|live
@namklabs
namklabs / add-www-alias.sh
Created Jan 22, 2016
alias www to your MAMP folder on OS X
View add-www-alias.sh
echo "alias www='cd ~/Desktop/www;clear;pwd;ls -a'" >> ~/.bash_profile
@namklabs
namklabs / php-process-user.php
Created Jan 20, 2016
find username executing PHP process
View php-process-user.php
# http://stackoverflow.com/questions/9557646/php-mkdir-permissions-denied-mac
$processUser = posix_getpwuid(posix_geteuid());
echo($processUser['name']);
You can’t perform that action at this time.