Skip to content

Instantly share code, notes, and snippets.

@mikeyledoux
mikeyledoux / jQuery Lib Loader
Last active October 14, 2015 00:27
Use this to load in a JS dependency on the fly, FROM your other js files. [usage examples at the bottom] Background: Sometimes we don't want to load every JS file we use on every page, because only certain pages use them. Sometimes we may not want to have to use our application framework make the decision about which JS file(s) to use. NOTE: Thi…
var myLIB = {
desc: 'This thing does neato stuff'
};
myLIB.init = function (lib_type, callback) {
"use strict";
if (typeof lib_type !== 'undefined'){
renderScript();
}
function renderScript() {
@abraham
abraham / index.html
Created October 29, 2012 02:50
ADN Widgets alpha install instructions
<html>
<head>
<!-- ADN Widgets alpha -->
<!-- Sign up for alpha deprecation announcements: https://groups.google.com/forum/#!forum/adn-widgets-announce -->
<!-- To install: include script on your web site and add the <a> tag where you want the follow button -->
<!-- Tested to work in the latest Chrome, Firefox, Safari, and IE9 -->
<!-- ADN Widgets: https://alpha.app.net/widgets -->
<script async src='https://adnwidgets.herokuapp.com/alpha.js'></script>
</head>
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@garnaat
garnaat / update_key.py
Created February 10, 2012 17:25
Update the content-type of an existing key in S3 using boto
import boto
s3 = boto.connect_s3()
bucket = s3.lookup('mybucket')
key = bucket.lookup('mykey')
# Copy the key onto itself, preserving the ACL but changing the content-type
key.copy(key.bucket, key.name, preserve_acl=True, metadata={'Content-Type': 'text/plain'})
key = bucket.lookup('mykey')
@spulec
spulec / pre-commit
Last active January 13, 2023 02:26
Yipit Pre-commit Hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^[MA]\s+(?P<name>.*)$')
CHECKS = [
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt