Skip to content

Instantly share code, notes, and snippets.

View omichelsen's full-sized avatar

Ole Bjørn Michelsen omichelsen

View GitHub Profile
@omichelsen
omichelsen / split-string-columns-to-table.sql
Created October 18, 2014 14:26
Split strings in columns to a new table
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
@omichelsen
omichelsen / cheatsheet.js
Last active November 20, 2021 16:51
JavaScript cheat sheet
// Random 0 to max (excl)
const random = (max) => Math.floor(Math.random() * max)
// Random between (min incl, max excl)
const random = (min, max) => Math.floor(Math.random() * (max - min) + min)
// Fill array
const arr = new Array(42).fill(0).map(() => random(1, 5))
// Remove duplicates from Array (tip: fallback using indexOf)
let chars = ['A', 'B', 'A', 'C', 'B']
@omichelsen
omichelsen / backup.sh
Created February 20, 2015 17:35
bash: backup mysql
#!/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 / emojis.js
Created April 27, 2016 18:51
JS: ascii smiley to emoji mapping
export const keys = Object.freeze({
'o/': '👋',
'</3': '💔',
'<3': '💗',
'8-D': '😁',
'8D': '😁',
':-D': '😁',
'=-3': '😁',
'=-D': '😁',
'=3': '😁',