Skip to content

Instantly share code, notes, and snippets.

View mokkabonna's full-sized avatar

Martin Hansen mokkabonna

  • Knowit Amende AS
  • Oslo, Norway
View GitHub Profile
@mokkabonna
mokkabonna / gist:9266784
Created February 28, 2014 07:24
Daily automatic backup/snapshots and purging for EC2 volumes
#!/bin/bash
#create snapshots of all volumes
aws ec2 describe-volumes | grep VOLUMES | cut -f 7 | while read volumeid; do aws ec2 create-snapshot --volume-id=$volumeid --description="daily-for-automatical-deletion" ; done
#delete all but the last 35 (if 5 volumes, this is keeping the daily automatic backups for the last 7 days)
aws ec2 describe-snapshots --owner-id=<insert-owner-id> --filters Name=description,Values="*for-automatical-deletion" | grep SNAPSHOTS | sort -r -k 6 | sed -n 35,1000p | cut -f 5 | while read snapshotid; do aws ec2 delete-snapshot --snapshot-id=$snapshotid; done
@mokkabonna
mokkabonna / gist:9584448
Created March 16, 2014 14:57
rename files
for file in *; do newname="$(cat $file | head -2 | tail -1 | cut -f 3 -d '[' | cut -d '(' -f 1).sublime-snippet"; mv "$file" "$newname"; done
@mokkabonna
mokkabonna / expect-promise.js
Created March 16, 2014 21:27
promises for expect.js
var eventually = {
expect: function(promise) {
function notBe(expectedValue) {
return promise.then(function(eventualValue) {
expect(eventualValue).not.to.be(expectedValue);
});
}
function be(expectedValue) {
@mokkabonna
mokkabonna / responsive-table
Created April 25, 2014 13:53
responsive-tables
<style>
table {
width:100%;
}
@media (max-width: 500px) {
table tr th {
float:left;
width:50%;
clear:left;
}
@mokkabonna
mokkabonna / gist:301e53b19e726fb9dd7e
Last active August 29, 2015 14:02
sinon shorter stack errors, add in assert.fail
fail: function fail(message) {
var error = new Error(message);
error.name = this.failException || assert.failException;
try{
throw error;
} catch(e) {
if (error.stack){
console.log(error.stack);
error.stack = error.stack.split('\n').slice(0,20).join('\n')
{
"adresse": "MARIDALSVEIEN 2",
"tiltak": {
"beslutningsTre": {
"id": "5",
"label": "Tiltaksliste ved bevaringsverdig eiendom",
"multipleSelect": true,
"beslutninger": [{
"id": "6",
"label": "Bytte vindu eller dør",
sudo apt-get install --no-install-recommends mutter
mutter --replace
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "intel"
Driver "intel"
BusID "PCI:0@0:2:0"
update-alternatives: using /usr/lib/nvidia-349-prime/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-349-prime/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode
sudo apt-get install python-setuptools
sudo easy_install pygments
echo "alias ccat='pygmentize -O style=monokai -f console256 -g'" >> ~/.bashrc