Skip to content

Instantly share code, notes, and snippets.

<?php
// Demo for session fixation
//
// Attacker creates a session by visiting the page: http://famfamfam.com/sessionfixation.php
// Attacker gets their session ID out of the cookie (or in this case from the page)
// Attacker creates a URL such as http://famfamfam.com/sessionfixation.php?PHPSESSID=attackerssessionid and sends it to victim
// Victim clicks the URL (now both the attacker and victim are using the same session)
// Victim logs in
// Now the attacker is logged in to the victim's account too (same session!)
@markjames
markjames / 0_reuse_code.js
Created May 4, 2016 15:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@markjames
markjames / git-extract.sh
Created February 28, 2012 11:38
git-extract for OSX - extracts all of the changes from a git repo between two revisions into a separate folder (git-extract.sh 5555..HEAD)
#!/bin/bash
BOLD="\033[1m"
_BOLD="\033[22m"
RED="\033[31m"
YELLOW="\033[33m"
GREEN="\033[32m"
RESET="\033[39m"
range=$1
@markjames
markjames / datediff.sql
Created February 20, 2012 11:19
Date Diff
SELECT
DATEDIFF(@oldDate,a.DisplayDate) AS 'Date Difference',
(@oldDate:=a.DisplayDate) as 'DisplayDate'
FROM
NewsPost a
<?php
// ...
function augmentSQL(SQLQuery &$query) {
// Get the content at a specific date
if($date = Versioned::current_archived_date()) {
foreach($query->from as $table => $dummy) {
if(!isset($baseTable)) {
$baseTable = $table;
// Browsermob Script
// This test emulates a single user visiting the homepage,
// and downloading any necessary assets
var httpSiteRoot = 'http://mydomain.cat/';
var assetRoot = 'http://mydomain.cat/static/';
var uploadRoot = 'https://s3-eu-west-1.amazonaws.com/mydomain.cat/';
// ==============================================
<?php
class ExtsViewableDataDecorator extends Extension {
/**
* Adds first/last/start/end class to a list item.
*
* Sometimes you need to:
* Lay out a load of thumbnails in a grid.
* Style only the first or last elements in a vertical/horizontal list of items
@markjames
markjames / Page.php
Created December 1, 2011 15:35
Silverstripe Snippets
<?php
// A new page type
class Page extends SiteTree {
static $icon = array('/site/icons/page.png?','file');
// Or if you have icons in multiple states:
// static $icon = '/site/icons/page';
// Allowed child types
#SalesList .FrontItem:before, #SalesList .FrontItem:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
#SalesList .FrontItem:after { clear: both; }
#SalesList .FrontItem { zoom: 1; }
@markjames
markjames / git.sh
Created September 1, 2011 10:04
Going git
# The following commands
# need to be run once to set-up git
# Install git (you may have this already, type git then hit [ENTER] in Terminal to check)
cd ~/Downloads && curl -OL "http://git-osx-installer.googlecode.com/files/git-1.7.6-x86_64-snow-leopard.dmg" && open ~/Downloads/git-1.7.6-x86_64-snow-leopard.dmg
# Start a new Terminal window
# I don't have a command for this one
# Install the Git Flow extension