Skip to content

Instantly share code, notes, and snippets.

View jstroem's full-sized avatar

Jesper Lindstrøm Nielsen jstroem

  • Uber
  • Aarhus, Denmark
View GitHub Profile
@jstroem
jstroem / history.sql
Last active November 25, 2015 08:09
A simple way to get a history log on a complete table without getting hurt on the SELECT performance.
//Replace `TABLE_NAME` with the name of the table
//Replace `DB_NAME` with the database name.
//Replace `PRIMARY_KEY` with the primary key of the `TABLE_NAME`
CREATE TABLE DB_NAME.TABLE_NAME_history LIKE DB_NAME.TABLE_NAME;
ALTER TABLE DB_NAME.TABLE_NAME_history MODIFY COLUMN PRIMARY_KEY int(11) NOT NULL,
DROP PRIMARY KEY, ENGINE = MyISAM, ADD action VARCHAR(8) DEFAULT 'insert' FIRST,
ADD revision INT(6) NOT NULL AUTO_INCREMENT AFTER action,
ADD dt_datetime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER revision,
@jstroem
jstroem / php-angular-config.js
Created June 29, 2014 15:27
Angular.js with PHP backend
app.config(['$httpProvider',
function($httpProvider) {
// Use x-www-form-urlencoded Content-Type
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function(data) {
return angular.isObject(data) && String(data) !== '[object File]' ? $.param(data) : data;
}];
}]);
@jstroem
jstroem / widgetInfoFromId.php
Created May 30, 2013 21:50
Widget info from widget ID (wordpress)
function getWidgetInfo($widgetId){
if (preg_match('/^(.+)-(\d+)$/', $widgetId, $matches)){
global $wp_widget_factory;
list($widgetId, $baseid, $instanceid) = $matches;
$widget_obj = null;
foreach($wp_widget_factory->widgets as $widget){
if ($widget->id_base == $baseid){
$widget_obj = $widget;
break;
}
@jstroem
jstroem / hw4.lhs
Last active December 14, 2015 12:38
CSE230 handin 4
---
title: Homework #4, Due Friday, March 8th
---
Preliminaries
=============
Before starting this part of the assignment,
1. Install the following packages
@jstroem
jstroem / Makefile
Last active December 12, 2015 10:09
CSE230 handin 3
SOEPATH=/Users/jstroem/Projects/cse230/SOE/src/
all:
ghc -i${SOEPATH} -hide-package parsec-3.1.3 --make hw3
test:
ghc -i${SOEPATH} -hide-package parsec-3.1.3 --make testing
clean:
rm -f *.hi *.o hw3 testing
@jstroem
jstroem / hw2.lhs
Last active December 11, 2015 20:09
CSE230 handin 2
---
title: Homework #2, Due Sunday 2/5/13
---
This week's homework is presented as a literate Haskell file,
just like the lectures. This means that every line beginning with
`>` is interpreted as Haskell code by the compiler, while every other
line is ignored. (Think of this as the comments and code being reversed
from what they usually are.)
You can load this file into `ghci` and compile it with `ghc`
@jstroem
jstroem / Test.hs
Last active January 21, 2016 17:44
CSE230 HW1
module Main where
import qualified Hw1 as H
import Text.Printf
main :: IO ()
main = do
putStrLn(printf "rectangle sides: %d" (H.sides (H.rectangle 2 3)))
putStrLn(printf "rtTriangle sides: %d" (H.sides (H.rtTriangle 2 3)))
putStrLn(printf "Polygon sides with 0 vertexes: %d" (H.sides (H.Polygon [])))
@jstroem
jstroem / Makefile
Created December 7, 2012 03:49
cse260 project standard NOT distribution
HOST = $(shell hostname)
BANG = $(shell expr match `hostname` ccom-bang)
BANG-COMPUTE = $(shell expr match `hostname` compute)
LILLIPUT = $(shell expr match `hostname` lilliput)
ifneq ($(BANG), 0)
PUB = /share/class/public/cse260-fa12
include $(PUB)/Arch/arch.gnu.generic
@jstroem
jstroem / Makefile
Created December 6, 2012 04:22
CSE260 project. ghost-cells and cyclic. NOT even distribution
HOST = $(shell hostname)
BANG = $(shell expr match `hostname` ccom-bang)
BANG-COMPUTE = $(shell expr match `hostname` compute)
LILLIPUT = $(shell expr match `hostname` lilliput)
ifneq ($(BANG), 0)
PUB = /share/class/public/cse260-fa12
include $(PUB)/Arch/arch.gnu.generic
@jstroem
jstroem / Makefile
Created December 6, 2012 04:18
CSE260 project. ghost-cells NOT distribution
HOST = $(shell hostname)
BANG = $(shell expr match `hostname` ccom-bang)
BANG-COMPUTE = $(shell expr match `hostname` compute)
LILLIPUT = $(shell expr match `hostname` lilliput)
ifneq ($(BANG), 0)
PUB = /share/class/public/cse260-fa12
include $(PUB)/Arch/arch.gnu.generic