Skip to content

Instantly share code, notes, and snippets.

View robbestad's full-sized avatar
🎯
Focusing

Sven Anders Robbestad robbestad

🎯
Focusing
View GitHub Profile
@robbestad
robbestad / foreach.php
Created June 30, 2013 20:21
Getting rid of foreach error
<?php
// double any value whose key starts with 'b'
$arr = array('a'=>1, 'b1'=>2, 'b2'=>3, 'c'=>4, 'd'=>5);
$non_array = null;
// Normal usage with an array
print "Test 1:\n";
foreach ($arr as $key => $val) {
print "Key $key, Value $val\n";
@robbestad
robbestad / hover.css
Created June 30, 2013 20:22
css image hover
.image {
/* image properties */
}
.image:hover {
-o-transition-duration: .33s;
-o-transition-property: border, color, opacity, -moz-opacity;
-webkit-transition-duration: .33s;
-webkit-transition-property: border, color, opacity, -moz-opacity;
filter:alpha(opacity=50);
@robbestad
robbestad / compress.php
Created June 30, 2013 20:27
Compress output in PHP
<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
@robbestad
robbestad / redirect-ie6.php
Last active December 19, 2015 04:19
Browser redirect with PHP for IE6
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua,'MSIE') != false && strpos($ua,'Opera') === false)
{
if (strpos($ua,'Windows NT 5.2') != false)
{
if(strpos($ua,'.NET CLR') === false) return;
}
if (substr($ua,strpos($ua,'MSIE')+5,1) < 7)
{
@robbestad
robbestad / .gitconfig
Created June 30, 2013 21:02
Git aliases
//add to ~/.gitconfig
[alias]
cp = cherry-pick
st = status -s
ci = commit
br = branch
co = checkout
df = diff --wrod-diff
lg = log -pm
@robbestad
robbestad / strip.sh
Created June 30, 2013 21:03
Get URL and Images
wget -O - 'http://www.elektroda.pl/' | \
grep -o '<img src=['"'"'"][^"'"'"']*['"'"'"]' | \
sed -e 's/^<img src=['"'"'"]//' -e 's/["'"'"']$//'
wget -O - http://stackoverflow.com | \
grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | \
sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//'
@robbestad
robbestad / gitrm.sh
Created June 30, 2013 21:06
GIT: remove all tracked files that have since been deleted
git rm $(git ls-files --deleted)
@robbestad
robbestad / ls.sh
Created June 30, 2013 21:08
bash ls aliases
//vim ~/.bashrc
/add
alias l='ls -Ahq --group-directories-first --color'
//run with full details files
l -l
@robbestad
robbestad / mergesort.php
Last active December 19, 2015 09:59
Quick sort and Merge sort algorithms written in PHP with explanations and pseudo code.
<?php
/*
** Merge sort algorithm
*
* @author: Sven Anders Robbestad
*
* These are algorithms I'm writing as part
* of a course on Stanford called
* Algorithms: Design and Analysis by Tim Roughgarden
@robbestad
robbestad / .vimrc
Last active December 21, 2015 20:39
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Hacks, etc.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" statusline
set laststatus=2
"let g:lightline = { 'colorscheme': 'wombat', 'component': { 'readonly': '%{&readonly?"⭤":""}', } }
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"⭤":""}',