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 / 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 / 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 / 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 / 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 / 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,