Skip to content

Instantly share code, notes, and snippets.

View bgoonz's full-sized avatar
🎯
learning

Bryan C Guner bgoonz

🎯
learning
View GitHub Profile
var Arch; if (!Arch) Arch = {}; // set up custom namespace 'Arch'
Arch.AjaxPagination = function(paginationContainer, storiesContainer, filtersContainer) {
// Only html5 browsers can use ajax pagination. We don't want no stinkin' hashbang URLs.
if (!history.pushState) {
return;
}
this.$paginationContainer = $(paginationContainer);
@sindresorhus
sindresorhus / git-pulley.sh
Created May 7, 2012 20:01
Git merge squash author commit and push - cheatsheet
git checkout master
git checkout -b bug123
git pull http://repourl.git branch
git log | grep "Author" | head -1 # get the author
git checkout master
git merge --squash bug123
git commit -a --author="Author" --message="Close #1: Title. Fixes #666"
git push origin master
@unders
unders / git commands.bash
Created October 20, 2012 15:22
Gist commands
Reference: http://gitimmersion.com/
# Pretty Git log
alias glog='git log --pretty="format:%C(yellow)%h %C(green)%s%C(blue)%d%C(white) - %ar - %an - %ad" --graph --date=short'
hist= log --pretty=format:\"%C(yellow)%h%Creset %ad | %C(green)%s%C(blue)%d%Creset [%an]\" --graph --date=short
# Reverting a Commit (safe in pushed to a remote branch)
git revert HEAD
# REMOVING COMMITS FROM A BRANCH
@sindresorhus
sindresorhus / instagram-recent-photos.js
Created October 21, 2013 09:33
Get recent photos from Instagram
function getRecentInstagramPhotos(userId, accessToken, count, cb) {
var url = 'https://api.instagram.com/v1/users/' + userId + '/media/recent?access_token=' + accessToken + '&count=' + count;
$.getJSON(url, function (response) {
cb(response.data);
});
}
var userId = '';
var accessToken = '';
getRecentInstagramPhotos(userId, accessToken, 20, function (photos) {
@sindresorhus
sindresorhus / get-latest-pic-facebook.js
Created October 28, 2013 13:16
Get latest picture from Facebook user using FQL
var endpoint = 'https://graph.facebook.com/fql';
var accessToken = '';
var userId = '';
var q = 'SELECT caption, src_big FROM photo WHERE aid IN(SELECT aid FROM album WHERE owner = ' + userId + ' ORDER BY modified DESC LIMIT 1) ORDER BY modified DESC LIMIT 1';
var url = endpoint + '?access_token=' + accessToken + '&q=' + q;
@vlandham
vlandham / Readme.md
Last active July 20, 2021 02:54
spectrogram

Interactive Spectrogram in the browser!

Same as example in: https://github.com/vlandham/spectrogramJS - but in blocks.

Click 'analyze' to play the sound and create spectrogram.

Uses web audio api.

Also uses D3 with canvas to display the main visualization.

@bendc
bendc / nodelist-iteration.js
Created January 13, 2015 14:39
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement
@ourmaninamsterdam
ourmaninamsterdam / LICENSE
Last active April 24, 2024 18:56
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@sindresorhus
sindresorhus / node-child-process-perf-sync-vs-async.md
Last active February 16, 2022 07:17
Results are as expected. Async comes with a slight overhead because of the event loop, but has many other benefits. So unless you know you won't need it, go for async.

Measuring sync vs async child processes in Node.js

  • macOS 10.12.3
  • Node.js 7.4.0

childProcess

const childProcess = require('child_process');
@NigelEarle
NigelEarle / cluster.js
Created November 9, 2017 17:20
Node.js cluster
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);
// Fork workers.
for (let i = 0; i < numCPUs; i++) {