Skip to content

Instantly share code, notes, and snippets.

View defaye's full-sized avatar

Jono Feist defaye

  • England
View GitHub Profile
@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
@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)) {
@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
@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
@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
@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;
}
@sunny
sunny / git-checkout.rake
Last active August 19, 2022 10:04 — forked from skyriverbend/rails_switch_branch.py
Task to checkout a branch in rails and apply or rollback the migrations between the two.
# encoding: UTF-8
#
# $ rake checkout new_branch_name
#
# Via https://gist.github.com/jonlemmon/4076864
#
# 1. Roll back any migrations on your current branch which do not exist on the
# other branch
# 2. Discard any changes to the db/schema.rb file
# 3. Check out the other branch
@kinopyo
kinopyo / gist:2343176
Created April 9, 2012 12:37
Override Devise RegistrationsController, override redirect path after updating user

Override Devise RegistrationsController

Overview

Here I'll show you

  • How to override devise registrations_controller(related to create/update user account)
  • How to change redirect path after updating user

Override RegistrationsController

@Necklaces
Necklaces / ufw_vpn_killswitch_tutorial.md
Last active February 28, 2024 22:13
GNU/Linux UFW VPN kill switch tutorial

GNU/Linux UFW VPN kill switch tutorial

This is a quick guide for setting up a kill switch using UFW (Uncomplicated FireWall). It is assumed you are using OpenVPN and optionally Network-Manager with network-manager-openvpn.

1. (Optional) IP Addresses

Before we can start we're going to need the IP address (or the IP addresses) of your VPN so that we can whitelist those later on, write them down. They are obviously going to be different for every VPN and VPNs with multiple servers, so I'll leave this up to you.

2. Install UFW

On some systems UFW is installed and enabled by default (Ubuntu, for example). Installation procedure is going to be different for every distribution of GNU/Linux, but it's usually something like

@simonhamp
simonhamp / AppServiceProvider.php
Last active March 26, 2024 15:56
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()