Skip to content

Instantly share code, notes, and snippets.

View stpe's full-sized avatar
👋
🏎💨

Stefan Pettersson stpe

👋
🏎💨
View GitHub Profile
@stpe
stpe / blodcentralen.json
Created June 3, 2015 08:57
blodlager json
{
"@attributes": {
"BloodBankCode": "021"
},
"RunTime": "2015-06-03T10:48:04",
"StockLevel": [
{
"@attributes": {
"BloodGroup": "0+"
},
@stpe
stpe / get.js
Created September 9, 2015 09:47
Get nested object properties (just another take on implementation)
function get(obj, path) {
var parts = path.split(/\]\[|\]\.|\[|\]|\./);
return parts
.reduce(function(o, x) {
return (typeof o == "undefined" || o === null) ? x : o[x];
}, obj);
}
// example: get(obj, "prop.foo[0][2].bar[3].zoom")
@stpe
stpe / gist:2949924
Created June 18, 2012 18:38
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@stpe
stpe / snippet.md
Created June 19, 2012 07:58 — forked from harthur/snippet.md
console.log() key binding for Sublime Text 2

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
  {
    "keys": ["super+shift+l"],
    "command": "insert_snippet",
    "args": {
      "contents": "console.log(${1:}$SELECTION);${0}"
 }, 
@stpe
stpe / TextOverflowModeFill-bug.c
Last active January 2, 2016 14:29
Code to reproduce GTextOverflowModeFill bug when word is wrapped starting with lowercase 'j' (using PebbleSDK-2.0-BETA4)
/*
Complete buildable project containing minimum sample code to reproduce bug:
https://dl.dropboxusercontent.com/u/20181/TextOverflowModeFill-bug.zip
Bug description:
Using a TextLayer with GTextOverflowModeFill seems to position the
leading 'j' out of place in wrapped words starting with 'j'.
Example screenshot of the 'j' out of place:
@stpe
stpe / hyperiterativ-form-example.json
Last active February 19, 2016 23:14
Hyperiterativ prototypning med Google Spreadsheets
{
"conditions": [
{
"id": "D001",
"value": "barn"
}
],
"id": "PERSONNUMMERID",
"label": "Personnummer för barnet",
"placeholder": "ååååmmddxxxx",
@stpe
stpe / Pebble wscript VERSION_LABEL
Created January 21, 2014 09:30
Modified Pebble wscript file. Read appinfo.json and generates appinfo.h which contain a define for VERSION_LABEL. http://forums.getpebble.com/discussion/10405/how-do-i-get-my-app-version-in-c-code
import json
top = '.'
out = 'build'
def options(ctx):
ctx.load('pebble_sdk')
def configure(ctx):
ctx.load('pebble_sdk')
@stpe
stpe / youtube_videoCategories.md
Last active November 15, 2016 10:22
YouTube Video Categories

Per regionCode.

US

  • Film & Animation
  • Autos & Vehicles
  • Music
  • Pets & Animals
  • Sports
  • Short Movies
@stpe
stpe / youtube_countries.json
Created January 26, 2017 16:08
YouTube Countries
{
"AF": "Afghanistan",
"AX": "Aland Islands",
"AL": "Albania",
"DZ": "Algeria",
"AS": "American Samoa",
"AD": "Andorra",
"AO": "Angola",
"AI": "Anguilla",
"AQ": "Antarctica",
@stpe
stpe / mantisconnect_json.php
Created March 17, 2012 22:26
Simple JSON wrapper of Mantis SOAP API
<?php
/**
* Example usage (using jQuery):
* var url = "/path/mantisconnect_json.php?name=mc_project_get_issues&project_id=0&page_number=1&per_page=10";
* $.getJSON(url, function(data) {
* $.each(data, function() {
* console.log(data.id + ': ' data.summary);
* });
* });
*/