Skip to content

Instantly share code, notes, and snippets.

Stig Lindqvist stojg

Block or report user

Report or block stojg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .gitconfig
pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
graph = log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short
co = checkout
st = status
ci = commit
br = branch
unstage = reset HEAD --
last = log -1 HEAD
stojg / session.php
Last active Sep 27, 2015
How to set a custom session id on a SilverStripe site
View session.php
// Start a new session with the token from the url, this will reinitialize the _SESSION
// Set the current session connected to the controller with an new instance with the proper _SESSION data
$session = new Session(isset($_SESSION) ? $_SESSION : null);
// Some test that this actually works
stojg /
Created Nov 10, 2011
Ubuntu puppet installation
sudo apt-get update
sudo apt-get install irb libopenssl-ruby libreadline-ruby rdoc ri ruby ruby-dev
cd /usr/local/src
sudo wget
sudo tar -xzf rubygems-1.5.2.tgz
cd rubygems-1.5.2
sudo ruby setup.rb
sudo update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.8 1
sudo gem update --system
# cd /tmp/ && wget && bash ./
sudo apt-get install libopenssl-ruby rdoc libopenssl-ruby1.8 libreadline-ruby1.8 libruby1.8 rdoc1.8 ruby1.8
cd /tmp/
tar xvzf facter-1.5.7.tar.gz
cd facter-1.5.7
sudo ruby install.rb
cd ..
rm -rf facter*
stojg / deploy.rb
Last active Sep 30, 2015
Capistrano recipe for SS
View deploy.rb
# This is an example of how I use capistrano in a sweet symphony to deploy a SilverStripe site.
# If you haven't installed capistrano yet, now would be a good time to do it.
# sudo gem install capistrano
# Have a look at for some tricks.
# Otherwise shows most vars
# And here is the original deploy.rb
stojg /
Created Feb 15, 2012
Some common git aliases
git config --global "log --pretty=format:'%Cred%h%Creset %C(yellow)%ci%Creset %s - %C(bold blue)%an%Creset'"
stojg / async-social-load.js
Last active Oct 3, 2015
Async loading of social jS with callbacks
View async-social-load.js
(function(d, s) {
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id, callback) {
if (d.getElementById(id)) {return;}
js = d.createElement(s);js.src = url; = id;js.async=true;
if(callback!=undefined) {
//Extra for internet explorer
js.onreadystatechange = function () { if(this.readyState == 'complete' || this.readyState == 'loaded') { callback(); } }
stojg / ContentAwareImage.php
Created Apr 23, 2012
Testing content aware cropping for SilverStripe Idea is that the automatic cropping will crop the most interesting part of the image
View ContentAwareImage.php
* ContentAwareImage
* @author stig
class ContentAwareImage {
protected static $start_time = 0.0;
stojg / remove-tmp-db.php
Created Jun 13, 2012
Remove SilverStripe test databases
View remove-tmp-db.php
* This script will drop all the databases that contains this string 'tmpdb'.
* Those databases are likely to be left over from a SilverStripe test run
* Usage: Make sure you change the db connection string below and run the
* script like:
* php remove-tmp-db.php
// Change this to your db connection
stojg / parse-xml.php
Last active Feb 11, 2019
Parsing a huge XML with closure in PHP
View parse-xml.php
// Open the XML
$handle = fopen('file.xml', 'r');
// Get the nodestring incrementally from the xml file by defining a callback
// In this case using a anon function.
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){
// Transform the XMLString into an array and
You can’t perform that action at this time.