Skip to content

Instantly share code, notes, and snippets.

View jasonhancock's full-sized avatar
meh

Jason Hancock jasonhancock

meh
View GitHub Profile
@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
@tobert
tobert / zeromq_log_forwarder.pl
Created March 21, 2012 14:51
A perl/ZeroMQ log forwarder
#!/usr/bin/perl
=head1 NAME
zeromq_log_forwarder.pl - read a log and forward over ZeroMQ
=head1 SYNOPSIS
zeromq_log_forwarder.pl --logfile /full/path/to/logfile
@lusis
lusis / cloudstack-centos6.conf
Created March 24, 2012 05:04
fairly unsafe cloudstack upstart script to set hostname
# cloudstack - Changes hostname
#
# changes hostname to match cloudstack instance name
# centos version (tested on CentOS 6)
description "Changes hostname"
start on started network
task
#!/usr/bin/env node
var Client = require('irc').Client;
// configuration
// irc. server names, guys to auto-op, etc
var botname = "opsangeles-bot";
var server = "chat.freenode.com";
var channel = [ "#opsangeles" ];
var opusers = [
@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:

@adamloving
adamloving / temporary-email-address-domains
Last active May 31, 2024 15:43
A list of domains for disposable and temporary email addresses. Useful for filtering your email list to increase open rates (sending email to these domains likely will not be opened).
0-mail.com
0815.ru
0clickemail.com
0wnd.net
0wnd.org
10minutemail.com
20minutemail.com
2prong.com
30minutemail.com
3d-painting.com
@christianchristensen
christianchristensen / language_vendors.md
Last active December 16, 2015 19:39
Vendorize all the things; dependable dependency management.

Vendorize

Vendoring dependencies can provide quite a bit of freedom: from properly specified versions to clearly defined isolation. There's also some interesting interplay with OS level (or external to the language) dependencies which can be handled with proper package management; see Dependency management for grown ups. This serves as a guide for similar usage across languages.

Go

$GOPATH

Research:

@jfryman
jfryman / gist:5808537
Created June 18, 2013 19:36
NagiosDB - Generate Nagios configs from Puppet Exported Resources + PuppetDB
#!/usr/bin/env ruby
#
# Nagios/PuppetDB config generator
#
# Based on concept from puppetdb-external-naginator
# https://github.com/favoretti/puppetdb-external-naginator
#
# Generates nagios configs from puppet(db) exported resources.
#
require 'rubygems'
@rafaelfelix
rafaelfelix / ec2tags.rb
Last active January 17, 2020 08:55 — forked from drohr/ec2tags.rb
Hack to get ec2 tags to facter. Depends on aws-cli (https://github.com/aws/aws-cli), jq (http://stedolan.github.io/jq/) and the JSON RubyGem (http://rubygems.org/gems/json)
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region #{region} | jq '[.Tags[] | {key: .Key, value: .Value}]'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|
@kendellfab
kendellfab / golang-json-marshall
Created August 16, 2013 22:35
Handling custom Json marshalling in golang.
type Whatever struct {
someField int
}
func (w Whatever) MarshalJSON() ([]byte, error) {
return json.Marshal(struct{
SomeField int `json:"some_field"`
}{
SomeField: w.someField,
})