Skip to content

Instantly share code, notes, and snippets.

@ErikAndreas
ErikAndreas / index.html
Created December 7, 2011 12:07
Spotify Apps Api - Tabs
<script type="text/javascript">
function init() {
console.log("init()");
sp = getSpotifyApi(1);
// detects arguments value for tab
sp.core.addEventListener("argumentsChanged", function (event) {
console.log('args changed', sp.core.getArguments());
});
}
</script>
@ErikAndreas
ErikAndreas / 0background.md
Last active December 18, 2015 16:49
Proof of concept of full stack and tooling for AngularJS i18n gettext-style using Jed, pybabel and po2json. UPDATE: will now be maintained at https://github.com/ErikAndreas/lingua and tooling at https://github.com/ErikAndreas/grunt-lingua

Been looking for a full stack including tools for gettext-style i18n with AngularJS.

  • Gettext-style support in markup (html and javascript) supporting singular, plural and interpolation/sprintf
  • Tooling for extraction of strings to be translated (to .pot) from html and javascript
  • Tooling for generating .json of .po files

Ended up (working proof of concept) with the following:

  • "lingua", an AngularJS module wrapping Jed
  • Some AngularJS bootstrapping
  • pybabel for xgettext style translations extraction (to .pot)
  • po2json for generating .json files (per translation) from .po files
@ErikAndreas
ErikAndreas / gist:6119825
Last active December 20, 2015 10:59
Node.js streaming upload (and no tmp file on disk) with Multiparty with pipe to gunzip
"use strict";
var multiparty = require('multiparty')
, http = require('http')
, util = require('util')
, zlib = require('zlib');
http.createServer(function(req, res) {
if (req.url === '/upload' && req.method === 'POST') {
var form = new multiparty.Form();
@ErikAndreas
ErikAndreas / app.js
Created March 14, 2014 14:39
Draft to git(lab?) webhooks forwarding to xmpp (ejabberd2) muc with node.js
var Client = require('node-xmpp-client'),
ltx = require('ltx'),
express = require('express'),
app = express();
room_jid = 'git@conference.im.domain.com',
room_nick = 'GIT';
// valid user on im server (im.domain.com)
var client = new Client({
jid: 'git@im.domain.com',
@ErikAndreas
ErikAndreas / PJAX with RactiveJS idea.md
Last active October 7, 2015 09:22
PJAX with Ractive.js

Got a repo for this now: https://github.com/ErikAndreas/pjax-ractivejs

Start from/change/extend https://github.com/thybag/PJAX-Standalone with

  • CommonJS format and Browserify
  • Q around Superagent for XHR Promises
  • No need to support more than data-pjax equivalent attribute
  • Same Ractive templates on client as well as server (Ractive is isomorphic)
  • Use Ractive for rendering of client side instead of PJAX "standard" of returning/render full html (also, page title element in response is hideous) and just return data (json) from server, kind of what twitter seem to be doing
@ErikAndreas
ErikAndreas / default.pp
Created May 7, 2014 10:32
Vagrant puppet nginx node.js nodemon on Ubuntu 14.04
group { 'puppet': ensure => 'present' }
File { ignore => '.svn' }
exec { 'apt-get update':
command => '/usr/bin/apt-get update'
}
package { 'python-software-properties':
ensure => present,
@ErikAndreas
ErikAndreas / iso.md
Last active August 29, 2015 14:01
Isomorphic Javascript
@ErikAndreas
ErikAndreas / page.md
Created May 3, 2017 12:43
https via Cloudflare with github pages on custom domain with redirect to www
  1. assuming you already have your domain, will use domain.com as example and you have your github pages, will use username.github.io as example
  2. register for cloudflare account
  3. get cloudflare nameservers for your domain, e.g xxx.ns.cloudflare.com and yyy.ns.cloudflare.com
  4. update dns settings for your domain with the cloudflare nameservers and check status (might take a while)
  5. cloudflare dns settings -> add 2 A records; name: domain.com, value 192.30.252.153 and value 192.30.252.154 as per github pages instructions
  6. cloudflare dns settings -> add cname record; name www, value (is an alias of) username.github.io
  7. cloudflare page rules -> domain.com/* forwarding URL https://www.domain.com/$1 301 permanent redirect
  8. cloudflare page rules -> http://www.domain.com/* Always use https
  9. settings on your github pages repo -> custom domain 'www.domain.com'
@ErikAndreas
ErikAndreas / ProcessUrlListController.cs
Last active October 30, 2017 11:57
.net core static httpclient async send multiple requests with auth token
private static HttpClient client = new HttpClient();
// send off reqs as fast as possible, then process them, arbitrary Item's, each having a Url to process
public async Task<ActionResult> ProcessUrlList(List<Item> items, string token)
{
var reqs = new List<Task<HttpResponseMessage>>();
foreach(var item in items)
{
reqs.Add(Req(item.Url, token));
}
@ErikAndreas
ErikAndreas / azure-functions.md
Last active March 27, 2018 08:59
Serverless, FaaS

Azure Functions (release 2, beta)

PROS

  • the only "big" provider supporting node.js LTS 8 (aws and gcp still on 6.x)
  • automated deploy using git (tested w bitbucket), use different function apps per env (dev, stage, prod etc) and map against branches
  • local dev environment

CONS

  • cli deploy very unstable
  • "function host not running" errors