Skip to content

Instantly share code, notes, and snippets.

View johnmichel's full-sized avatar
👻
☕️

John Michel johnmichel

👻
☕️
View GitHub Profile
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 20, 2025 09:05
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@jakemarsh
jakemarsh / gist:592329
Created September 22, 2010 19:28
Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Your users will thank you. A lot.
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.view endEditing:YES];
}
//The endEditing: method on UIView comes to us from a category that UITextField adds to UIKit that makes the view or any subview that is the first responder resign (optionally force), that's what the "YES" bit is.
<?php header('HTTP/1.0 500 Internal Server Error'); exit; ?>
@cowboy
cowboy / webkit_inspector_font_size.sh
Created October 13, 2010 12:55
Increase WebKit Inspector's font size (probably will need to re-run after updates)
#!/bin/bash
sudo find '/Applications/Google Chrome.app' \
\( -name inspector.css -or -name devTools.css \) \
-exec sh -c 'cat >> $1 <<WAT
/* Added on `date` */
#drawer .monospace,
#drawer .source-code {
font-size: 18px !important;
@jonathanconway
jonathanconway / gist:652644
Created October 29, 2010 00:33
Load the current querystring parameters into an associative array, taking into account repeated keys
// By JonathanConway.net
// Based off original code by Andy E. http://stackoverflow.com/questions/901115/get-querystring-values-with-jquery/2880929#2880929
Object.prototype.isArray = function () {
/// <summary>
/// Returns true if this object is an array.
/// </summary>
return !(this.push === undefined);
};
@cowboy
cowboy / ba-curry.js
Created November 30, 2010 01:59
JavaScript Curry
/*!
* JavaScript Curry - v0.1pre - 11/29/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function curry(/* n,*/ fn /*, args...*/) {
@Kilian
Kilian / annoying.js
Created January 6, 2011 15:04
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
// ==UserScript==
// @include http://www.google.*/
// @include http://www.google.*/search*
// @include http://www.bing.com/
// @include http://www.bing.com/search*
// @include http://www.yahoo.com/
// @include http://search.yahoo.com/search*
// ==/UserScript==
document.querySelector('input[name=q], input[name=p]').value = " -w3schools";
@dirkstoop
dirkstoop / clearsvnentries.py
Created March 15, 2011 18:37
Recursively clear those pesky .svn folders from a directory
#!/usr/bin/env python
#
# clearsvnentries.py
# scripts
#
# Created by Dirk on 2009-06-03.
# Copyright 2009 Sofa BV. Use for good, not bad.
#
import os