Skip to content

Instantly share code, notes, and snippets.

View Thorsson's full-sized avatar
🎯
Focusing

Ivan Turkovic Thorsson

🎯
Focusing
View GitHub Profile
(function(){
'use strict';
angular
.module('app', [])
.directive('ngInsert', ngInsert)
.directive('ngInsert', ngInsertFillContentDirective);
ngInsert = ['$templateRequest', '$anchorScroll', '$animate', '$sce'];
function ngInsert($templateRequest, $anchorScroll, $animate, $sce) {
@Thorsson
Thorsson / rds_ri_prices_parser.rb
Created August 15, 2017 09:01 — forked from shinsaka/rds_ri_prices_parser.rb
AWS RDS RI pricing parser
#!/usr/bin/env ruby
require 'json'
def parse(uri)
JSON.parse `curl -s #{uri}`.gsub(/\/\*(?:(?!\*\/).)*\*\//m, '').strip.gsub(/^callback\(/, '').gsub(/\);/, '').gsub(/([a-zA-Z]+[0-9]*):/, '"\1":')
end
puts %w(
platform
@Thorsson
Thorsson / ofPropertyPathChanges.js
Created February 1, 2017 14:26 — forked from jayphelps/ofPropertyPathChanges.js
RxJS observable of property value changes, given an object and property path
function isObject(value) {
// Avoid an old bug in Chrome 19-20
// See https://code.google.com/p/v8/issues/detail?id=2291
const type = typeof value;
return type === 'function' || (!!value && type === 'object');
}
function ofPropertyChanges(obj, key) {
if (isObject(obj) === false) {
return Rx.Observable.return(undefined);
@Thorsson
Thorsson / Gemfile
Created January 17, 2017 15:27 — forked from goncalvesjoao/Gemfile
Changes you need to make in order to make Devise use JWT Header Authentication
# Add the "https://github.com/jwt/ruby-jwt" gem to your "Gemfile"
gem 'jwt'
@Thorsson
Thorsson / README.md
Created October 25, 2016 08:46 — forked from pbojinov/README.md
Two way iframe communication

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@Thorsson
Thorsson / wantsJSON.js
Created September 13, 2016 14:30 — forked from leereamsnyder/wantsJSON.js
Detect if a request in Express is for HTML or JSON
/*
Usage:
var jsoncheck = require('./wantsJSON') // path to file with this middleware function
app.use(jsoncheck)
app.get('/', function(req,res,next){
if (req.wantsJSON) {
// serve JSON
}
if (req.wantsHTML) {
@Thorsson
Thorsson / Dockerfile
Created August 9, 2016 18:36 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
@Thorsson
Thorsson / gist:47b073b83f082c221d0bbb3c4bca6ec7
Created May 1, 2016 21:32 — forked from kublaios/gist:f01cdf4369c86ddd6d71
Making a PEM File for iOS Push Notifications (From Ray Wenderlich's tutorial)
# Convert the .cer file into a .pem file:
$ openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
# Convert the private key’s .p12 file into a .pem file:
$ openssl pkcs12 -nocerts -in PushChatKey.p12 -out PushChatKey.pem
# Finally, combine the certificate and key into a single .pem file
$ cat PushChatCert.pem PushChatKey.pem > ck.pem
# At this point it’s a good idea to test whether the certificate works.

Develop locally with Elasticsearch on OSX using Docker

Docker

Docker does not run natively on OSX, only Linux. Docker Machine was created to add a Linux VM environment to run Docker containers on OSX. Install using Homebrew:

brew install docker
brew install docker-machine
docker-machine create
@Thorsson
Thorsson / Gemfile
Created January 28, 2014 14:05 — forked from vhodges/Gemfile
source 'http://rubygems.org'
gem "hiredis", "~> 0.3.1"
gem "em-synchrony"
gem 'em-hiredis'
#gem "redis", "~> 2.2.0", :require => ["redis/connection/synchrony", "redis"]
gem "goliath"
#gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git'