Skip to content

Instantly share code, notes, and snippets.

Ole Bjørn Michelsen omichelsen

Block or report user

Report or block omichelsen

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
@omichelsen
omichelsen / running-total-sql-server-2012.sql
Created Oct 17, 2014
Calculate a running total in SQL Server 2012
View running-total-sql-server-2012.sql
CREATE TABLE #TestData (
id int not null identity(1,1) primary key,
account varchar(10) not null,
deposit int not null
);
INSERT INTO #TestData (account, deposit) VALUES ('Vacation', 10)
INSERT INTO #TestData (account, deposit) VALUES ('Vacation', 20)
INSERT INTO #TestData (account, deposit) VALUES ('Vacation', 30)
INSERT INTO #TestData (account, deposit) VALUES ('Bills', 40)
INSERT INTO #TestData (account, deposit) VALUES ('Bills', 50)
@omichelsen
omichelsen / backup.sh
Created Feb 20, 2015
bash: backup mysql
View backup.sh
#!/bin/sh
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin
#----------------------------------------------------
# a simple mysql database backup script.
# version 2, updated March 26, 2011.
# copyright 2011 alvin alexander, http://devdaily.com
#----------------------------------------------------
# This work is licensed under a Creative Commons
# Attribution-ShareAlike 3.0 Unported License;
@omichelsen
omichelsen / split-string-columns-to-table.sql
Created Oct 18, 2014
Split strings in columns to a new table
View split-string-columns-to-table.sql
declare @table table(id int, strings nvarchar(400))
insert into @table (id, strings)
select 1, 'abc,def,ghi'
union all
select 2, 'jkl'
union all
select 3, 'mno,pqr'
select * from @table
View guid.js
export function create() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var guid = require('js/guid');
@omichelsen
omichelsen / emojis.js
Created Apr 27, 2016
JS: ascii smiley to emoji mapping
View emojis.js
export const keys = Object.freeze({
'o/': '👋',
'</3': '💔',
'<3': '💗',
'8-D': '😁',
'8D': '😁',
':-D': '😁',
'=-3': '😁',
'=-D': '😁',
'=3': '😁',
View .bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
# Programs
# ------------------------------------------------------------------------------
alias subl="open -a /Applications/Sublime\ Text\.app"
alias vsc="open -a /Applications/Visual\ Studio\ Code.app"
alias sim="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
# less syntax highlight
LESSPIPE=`which src-hilite-lesspipe.sh`
@omichelsen
omichelsen / feature-flip-data-rules.js
Last active Jul 7, 2016
Feature flipping data and rules
View feature-flip-data-rules.js
const data = {
browser: {
name: 'Chrome',
version: '52.4.53.123',
os: 'Mac'
},
env: 'development',
settings: {
audioConference: {
release: '2016-10-23 22:34:12'
@omichelsen
omichelsen / .editorconfig
Last active Mar 8, 2016
Default editorconfig with tabs and 4 spaces
View .editorconfig
root = true
[*]
indent_style = tab
indent_size = 4
View logger.js
export const LogLevels = {
log : 0,
info : 1,
warn : 2,
error : 3
}
function clone(arr) {
return arr.map(a => JSON.parse(JSON.stringify(a)))
}
@omichelsen
omichelsen / gist:8464951
Created Jan 16, 2014
JavaScript async remote
View gist:8464951
(function (window, document) {
var settings = {
dataId: 'data-myModule-id',
url: '/api/mymodule/'
};
function load() {
var elems = document.querySelectorAll('[' + settings.dataId + ']');
if (!elems) {
You can’t perform that action at this time.