Skip to content

Instantly share code, notes, and snippets.

⨀_⨀
⨂_⨂
(/◔ ◡ ◔)/
°ﺑ°
(¬_¬)
(´・ω・`)
(ʘ_ʘ)
(ʘ‿ʘ)
(๏̯͡๏ )
(◕_◕)
@einarlove
einarlove / toggle-audio-output.scpt
Created January 11, 2014 22:04
This NSApplescript toggles between the Internal Speakers and Apple TV. Could be saved as a service and triggered by keyboard shortcut or as an Alfred workflow
(*
-- Change audio output between two outputs
-- Bind to a keyboard shortcut or an Alfred keyword
--
-- @author Einar Löve <einar@unfold.no>
-- @link http://github.com/einarlove
*)
set defaultOutput to "Internal Speakers"
set alternativeOutput to "Apple TV"
var listofSumsWithnoRate = [109012, 118837, 129547, 141222, 153950, 167824, 182949, 199437, 217411, 237005, 258364, 281649, 307032, 334703, 364868, 397751, 433598, 472675, 515274, 561713]
var listOfKLPSums = [108791, 118355, 128760, 140080, 152394, 165792, 180367, 196223, 213474, 232240, 252657, 274869, 299033, 325322, 353921, 385035, 418884, 455709, 495772, 539356]
function cal(deposit, year, yield, rate){
while(year--){
deposit = (deposit * yield) * (1 - rate)
}
return Math.round(deposit)
}
/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
@einarlove
einarlove / require.sublime-snippet
Last active August 29, 2015 14:13
Sublime snippet for require syntax
<snippet>
<content><![CDATA[
var ${1} = require('${2:${1/(?<=.)([A-Z])/-\L$0/g}}')
]]></content>
<tabTrigger>require</tabTrigger>
<scope>source.js</scope>
</snippet>
<!--
Example:
@einarlove
einarlove / retinaBorder.styl
Last active August 29, 2015 14:16
Add retina pixel border with gradients
retinaBorder(top = false, right = false, bottom = false, left = false)
retinaGradients = ''
retinaSizes = ''
if top
retinaGradients += createGradient(top, 'top', appending: retinaGradients ? true : false)
retinaSizes = appendSize('100% 1px', retinaSizes)
if right
retinaGradients += createGradient(right, 'right', appending: retinaGradients ? true : false)
@einarlove
einarlove / gist:83746105b5cb24574b19
Last active September 23, 2015 07:45
pipe error log fra EarlyBird Backend
Request header
GET /api/routes/SK4603 HTTP/1.1
Host: einar.unfold.no:5000
Connection: keep-alive
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI5MzAzMjUxNSIsImp0aSI6IjU4ODEiLCJwaG9uZU51bWJlciI6IjkzMDMyNTE1IiwiYWNjZXB0ZWRUZXJtcyI6IjIifQ.VgWF0NaEDe8_Kqpf_sSzidQHMiODuNaKgqnAiXSSXn0
Referer: http://einar.unfold.no:5000/legg-til-reise?returnTo=/min-profil
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,nb;q=0.6
@einarlove
einarlove / Delay.jsx
Created February 8, 2016 20:16
Delay for ReactMotion
import React, {Component} from 'react';
import {render} from 'react-dom';
import {Motion, spring} from 'react-motion';
// helper to delay a prop being passed by `period` ms
class Delay extends Component{
static defaultProps = {
period: 0
};
state = {
@einarlove
einarlove / avinor-destiantions.txt
Created February 9, 2016 14:15
Destinasjoner via Avinor flyplasser rangert i lengde
3
KGS – Kos
4
ALF – Alta
BOO – Bodø
DOH – Doha
FAO – Faro
NCE – Nice
OSL – Oslo
@einarlove
einarlove / fetch.js
Created February 20, 2016 14:23
Fetch decorator sketches
@connectData({
fetch: fetchMeals,
fromState: state => ({
meal: state.meals[state.profile.preferredMeal]
mealToOld: state.meals[state.profile.preferredMeal].created > new Date()
}),
})