Skip to content

Instantly share code, notes, and snippets.

@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
@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 = [
@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')
@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:

@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>
@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() {
@mshmsh5000
mshmsh5000 / gist:4664829
Last active December 11, 2015 21:48
Magento: Temporary fix for failed configuration saves. See http://screencast.com/t/7yGn07BMGSY
<?php
// app/code/core/Mage/Adminhtml/Model/Config/Data.php: 135:
/**
* Get field backend model
*/
$backendClass = $fieldConfig->backend_model;
if (!$backendClass) {
$backendClass = 'core/config_data';
@robdodson
robdodson / Default (OSX).sublime-keymap
Created March 30, 2013 17:12
open current file in finder
{ "keys": ["super+shift+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} }
@Vinai
Vinai / fix-url-keys.php
Last active September 2, 2022 16:24
This fixes the duplicate url_key issue in a Magento 1.8 / 1.13 installation.
<?php
/**
* Drop this into the shell directory in the Magento root and run with -h to see all options.
*/
require_once 'abstract.php';
/**
* Fix duplicate url keys for categories and products to work with the 1.8 alpha1 CE url key constraints.
[idcmp@idcmp ~]$ cat ~/bin/git-start
#!/bin/bash
PREFIX=`date +%b%d | tr [:upper:] [:lower:]`
if [ -z "$1" ]; then
echo "Please specify the jira issue."
exit 1
fi