Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
CMCDragonkai / MY_Security.php
Created January 6, 2014 07:07
PHP: Codeigniter CSRF functionality does not support putting the CSRF token in the HTTP headers for the purposes of the double submit cookie method. It also only runs the CSRF check on POST and not on PUT or DELETE. This drop in MY_Security.php makes sure CSRF runs on POST, PUT or DELETE and checks the HTTP headers for X-XSRF-TOKEN recommended b…
<?php
class MY_Security extends CI_Security{
//overriding the normal csrf_verify, this gets automatically called in the Input library's constructor
//verifying on POST and PUT and DELETE
public function csrf_verify(){
$request_method = strtoupper($_SERVER['REQUEST_METHOD']);
@jbenet
jbenet / simple-git-branching-model.md
Last active May 3, 2025 18:07
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

4> [self() ! X || X <- [rhythm,music,'my girl']].
[rhythm,music,'my girl']
5> flush().
Shell got rhythm
Shell got music
Shell got 'my girl'
ok
@theycallmeswift
theycallmeswift / fizzbuzz.erl
Last active December 21, 2015 11:49
Fizzbuzz implemented in Erlang
%% DISCLAIMER: Please excuse my style, I don't write erlang.
-module(fizzbuzz).
-export([fizz_buzz/0]).
fizz_buzz() ->
fizz_buzz(1).
fizz_buzz(N) when N =< 100 ->
if
N rem 15 == 0 ->
@nmilford
nmilford / 00_hello_world.markdown
Last active September 5, 2018 13:53
A quick, non-conclusive, non-scientific tete-a-tete HelloWorld off for poops-n-giggles.

Inspired by https://gist.github.com/josevalim/1582864

Environment

Ubuntu 12.04

Linux citadel 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

  • 12G of DDR3 RAM (@ 1033MHz)
  • 16 cores (E5530 @ 2.40GHz)
@clouddueling
clouddueling / MainCtrl.js
Last active November 3, 2022 13:26
How to authenticate using AngularJS
controllers.controller('MainCtrl', function($scope, $location, Facebook, $rootScope, $http, $location, Upload, Auth, User, Question, Category, Serie, Record, Location, Popup, Process, Card, Question) {
$scope.$on('authLoaded', function() {
$scope.isExpert($scope.main.serieId);
$scope.isMember($scope.main.serieId);
});
$scope.loadAuth = function() {
Auth.load().success(function(data) {
$scope.main.user = data.user;
$scope.$broadcast("authLoaded");
@AlbertMoscow
AlbertMoscow / roman_numerals.exs
Last active October 26, 2019 05:21
Roman Numerals kata implemented in elixir
defmodule RomanNumerals do
@moduledoc """
Task definition: Create a function taking a positive integer as its parameter and
returning a string containing the Roman Numeral representation of that integer.
"""
def convert(number) do
convert(number, [[10,'X'], [9,'IX'], [5,'V'], [4,'IV'], [1,'I']])
end
defmodule ApplicationRouter do
use Dynamo.Router
prepare do
# Pick which parts of the request you want to fetch
# You can comment the line below if you don't need
# any of them or move them to a forwarded router
conn.fetch([:cookies, :params])
end
@manpages
manpages / elixir-newbie-digest-002.md
Last active December 11, 2015 22:39
Elixir Newbie Digest, Issue 2

Intro

Today I'll cover three basic topics:

  • Mistakes and misuses every Erlanger does when he starts to write in Elixir

  • Dependencies and Mix

  • Writing OTP-enabled Elixir applications

@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.