Skip to content

Instantly share code, notes, and snippets.

View timbillstrom's full-sized avatar

Tim Billström timbillstrom

View GitHub Profile
@timbillstrom
timbillstrom / svenska_län.json
Created January 29, 2017 21:45
Sveriges alla län i JSON-array, i objekten för respektive län så har vi namn och slug.
[
{
"name": "Blekinge",
"slug": "blekinge"
},
{
"name": "Dalarna",
"slug": "dalarna"
},
{
@timbillstrom
timbillstrom / sv.yml
Created January 26, 2017 11:55
Ruby on Rails internationalization file for distance_in_words in Swedish.
sv:
hello: "Hej världen"
datetime:
distance_in_words:
less_than_x_minutes: "mindre än en minut sedan"
about_x_minutes:
one: "ungefär en minut sedan"
other: ! "ungefär %{count} minuter sedan"
x_minutes:
one: "en minut sedan"
@timbillstrom
timbillstrom / waze-types.json
Created January 3, 2017 15:58
Waze API Types
POLICE
- POLICE_HIDING // Gömd poliskontroll
- POLICE_VISIBLE // Poliskontroll
HAZARD
- HAZARD_ON_SHOULDER_CAR_STOPPED // Fordon har stannat på vägrenen
@timbillstrom
timbillstrom / IVR.json
Last active December 16, 2016 15:32
46Elks incoming call params
{
"to":"+467668614100",
"direction":"incoming",
"from":"+467383931100",
"result":"newincoming",
"callid":"cae4eb39e3ea72caa36bb254c94760930"
}
@timbillstrom
timbillstrom / notify_46elks.sh
Created December 9, 2016 13:37
Bash - Check status for API, if status is unknown PING admin via SMS. To avoid extra text messages that day we save a textfile with a prefix specific to the day of alert.
#!/bin/bash
response=$(curl http://localhost:3000/api/status)
alert () {
curl -X POST \
-u username:password \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "from=BRON" \
-d "message=Status for API is unknown! 😭" \
-d "to=+467900000" \
@timbillstrom
timbillstrom / dropbox_backup.sh
Created December 9, 2016 13:30
Bash - Backup DB and site files to Dropbox folder.
#!/bin/bash
backup_path="/backup/$(date +"%y-%m-%d")/$(date +"%H-%M")-backup"
initdump () {
mkdir -p /tmp_backup
dump
storage
}
dump () {
@timbillstrom
timbillstrom / resize_nocrop_noscale
Created September 21, 2016 19:58 — forked from maxivak/resize_nocrop_noscale
Crop and resize an image using MiniMagick in Ruby on Rails. Two approaches.
def resize_nocrop_noscale(image, w,h)
w_original = image[:width].to_f
h_original = image[:height].to_f
if w_original < w && h_original < h
return image
end
# resize
image.resize("#{w}x#{h}")
@timbillstrom
timbillstrom / trafikinformation.html
Created December 17, 2014 00:52
Dintur.se - Trafikinformation
<section id="trafficInfo">
<div class="clickable all clicked" style="display: none;">
<h2>Trafikinfo (3)</h2>
<span id="chooseArea">Område<span></span></span>
</div>
<div class="clickable omrade omrade14 clicked" style="display: inline-block;">
<h2>Trafikinfo: Matfors (1)</h2>
{
"songs":[{
"title":"UFO",
"album":"UFO",
"artist":"Vigiland",
"duration":"144",
"spotify_song":"spotify:track:3zYqHQ4tu4pB2acp9Lltnz",
"spotify_album":"spotify:album:6kfTbuVKwpTPfzMwcDE0Sz",
"spotify_artist":"spotify:artist:3tLYpanVDomWAZqF82NPds",
{"payload":{"actions":[{"cmd":"replace","target":"m_more_friends","html":"\u003Cdiv&gt;\u003Cdiv class=\"item _cs2 acw abt\" data-sigil=\"undoable-action marea\"&gt;\u003Cdiv class=\"ib cc _1aj4\"&gt;\u003Ca class=\"darkTouch _1aj5 l\" href=\"\/filip.vi.5?fref=fr_tab&amp;amp;pn_ref=friends_all\"&gt;\u003Ci class=\"img profpic\" aria-label=\"Filip Vi\" role=\"img\" style=\"background:#d8dce6 url(&amp;quot;https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xpa1\/v\/t1.0-1\/p480x480\/10422291_1533076660265315_4414758563003550678_n.jpg?oh=6b32c59d139148beae3134df79266fe2&amp;amp;oe=55036A3D&amp;amp;__gda__=1427045183_ef0807ed19a04ac841079dad51329e6f&amp;quot;) no-repeat center;background-size:100\u0025 100\u0025;-webkit-background-size:100\u0025 100\u0025;width:48px;height:48px;\" data-sigil=\"touchable\"&gt;\u003C\/i&gt;\u003C\/a&gt;\u003Cdiv class=\"_4mn c\"&gt;\u003Ca href=\"\/filip.vi.5?fref=fr_tab&amp;amp;pn_ref=friends_all\"&gt;\u003Cdiv class=\"_4mo\"&gt;\u003Cstrong&gt;Filip Vi\u003C\/strong&gt;\u003C\/d