Skip to content

Instantly share code, notes, and snippets.

diff --git a/pagify.js b/pagify.js
index 051f1ce..577d798 100644
--- a/pagify.js
+++ b/pagify.js
@@ -23,7 +23,10 @@
// Run after loading if caching, otherwise run immediately
var runAfterLoading = function() {
self.switchPage = function(page) {
- page = page || window.location.hash.replace('#','');
+ if(!page){ //if there's no page selected, go back to the default
@Sequoia
Sequoia / get_schema.php
Created January 24, 2012 17:50
A simple php+bash script to output the db schema in the nicely formatted mysql c client way (w/o reproducing the formatting work)
<?php
//I'd add a shebang line but my php is /usr/local/zend/... and yours probably isn't
//if you want to run it that way, make sure to offset the argv keys by -1
//explain usage
if( !isset( $argv[1] ) ){
echo "Describes all tables in the nice mysql c client way\n";
echo "Usage: php " . basename(__FILE__) . " [username] [password] [database]";
die("\n");
}
@Sequoia
Sequoia / mentions_of.php
Created February 1, 2012 18:01
count some the languages mentioned in the HN jobs listings.
<?php
//explain usage
if( !isset( $argv[1] ) ){
echo "Usage: php " . basename(__FILE__) . " [url]";
die("\n");
}
$languages = array( 'python'=>0, 'php'=>0, 'node'=>0, 'ruby'=>0, 'java'=>0, 'javascript'=>0 );
$length = count( $languages );
$url = $argv[1];
@Sequoia
Sequoia / jpgtoSetup.sh
Created February 21, 2012 20:12
jpgto bash function
function jpgto(){
local jptkeyword=$1;
local jptpath=$2;
curl -silent -F keyword=$jptkeyword -F file="@$jptpath" jpg.to/finish.php >> /dev/null;
echo "http://jpg.to/$jptkeyword";
}
[you@home]$ jpgto delicious /path/to/cake.jpg
@Sequoia
Sequoia / gist:2641378
Created May 9, 2012 02:39
jasmine-node test spec causes node to throw
var Afonigizer = require('../afonigizer.js').Afonigizer;
var _ = require('../node_modules/underscore/underscore.js');
describe("The Afonigizer", function(){
'use strict';
var afonigizer, i;
beforeEach(function(){
afonigizer = new Afonigizer(Math);
@Sequoia
Sequoia / scrapeFBphotos.js
Created August 17, 2012 02:07
Gather Photos from a facebook gallery
//you must be viewing from the overlay view (the inline-page view changes page on next-click)
// 1. run in console
// 2. copy links from console when it's done
// 3. paste into imgur.com or whatevs
var imagesArray = [];
var repeatClickLog;
var logAndClick = function(){
if(document.querySelector('.videoStage').childNodes.length){
@Sequoia
Sequoia / atlassian_footindoor.js
Created September 28, 2012 21:12
keep jira session active
// ==UserScript==
// @name Keep the page open
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match https://ssp.ptc.com/jira/*
// @copyright 2012+, You
// ==/UserScript==
setInterval(function(){
@Sequoia
Sequoia / Custom.css
Created October 5, 2012 16:42 — forked from bentruyman/Custom.css
IR_Black Theme for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@Sequoia
Sequoia / gist:4687394
Created January 31, 2013 22:47
Disk space cost of a mongo database with a single collection with a single document with a single key with a single digit: 211 MB
[523]$ mongo asdf
MongoDB shell version: 2.0.4
connecting to: asdf
> db.a.insert({a:1});
>
bye
17:42:36-diamonds:wk2
[524]$ sudo du -sh /var/lib/mongodb/asdf.
asdf.0 asdf.1 asdf.ns
17:42:36-diamonds:wk2
@Sequoia
Sequoia / my-first-io-problem
Created October 22, 2013 18:50
It looks to me like there are **nine lines**, not eight. What am I missing?
h2.Code
```javascript
var fs = require('fs');
var filename = process.argv[2];
var fileBuffer = fs.readFileSync(filename);
//get # of lines in `contents` Buffer
var lines = fileBuffer.toString().split("\n");
lines.forEach(function(line,index){//remove \r's
lines[index] = line.replace(/\r/,'');