Skip to content

Instantly share code, notes, and snippets.

View defaye's full-sized avatar

Jono Feist defaye

  • England
View GitHub Profile
@kohnmd
kohnmd / flatten.php
Last active September 20, 2021 12:48
Function to recursively flatten multidimensional PHP array.
<?php
// Requires PHP 5.3+
// Found here: http://stackoverflow.com/a/1320156
function flatten_array(array $array) {
$flattened_array = array();
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; });
return $flattened_array;
}
@jasonrobertfox
jasonrobertfox / commit-msg
Last active August 15, 2021 10:05
This is a commit-msg hook for git that will validate your commit message to conform to the rules outlined in http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html It's a ruby adaptation of the hook outlined in http://addamhardy.com/blog/2013/06/05/good-commit-messages-and-enforcing-them-with-git-hooks/ (Thanks Addam Hardy!)
#!/bin/sh
exec < /dev/tty
./.git/hooks/validate_commit.rb $1
@jordelver
jordelver / gist:3790808
Created September 26, 2012 21:45
Destructuring assignment in Ruby and splats!
# Destructuring assignment in Ruby
# http://po-ru.com/diary/destructuring-assignment-in-ruby/
numbers = [ 1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
# Destructuring assignment
a, b, c = numbers
@jcamenisch
jcamenisch / .profile fragment
Created January 24, 2012 19:19
Lightning-fast project-wide find/replace with git grep and sed
gg_replace() {
if [[ "$#" == "0" ]]; then
echo 'Usage:'
echo ' gg_replace term replacement file_mask'
echo
echo 'Example:'
echo ' gg_replace cappuchino cappuccino *.html'
echo
else
find=$1; shift
@basuke
basuke / gen-security.php
Created April 20, 2011 10:08
Generate CakePHP configuration value for security, Security.salt and Security.cipherSeed.
<?php
$salt = genrandom(40);
$seed = genrandom(29, "0123456789");
echo "\tConfigure::write('Security.salt', '$salt');\n";
echo "\tConfigure::write('Security.cipherSeed', '$seed');\n";
function genrandom($len, $salt = null) {
if (empty($salt)) {
@nogweii
nogweii / plugin.rb
Last active August 29, 2015 13:57
steam login plugin for discourse
# name: discourse-steam
# about: VALVE's Steam login support for Discourse
# version: 0.0.1
# authors: Colin Shea
auth_provider :title => 'with Steam',
:authenticator => Auth::OpenIdAuthenticator.new('steam','http://steamcommunity.com/openid', trusted: true),
:message => 'Authenticating with Steam (make sure pop up blockers are not enabled)',
:frame_width => 1000, # the frame size used for the pop up window, overrides default
:frame_height => 800