Skip to content

Instantly share code, notes, and snippets.

View arvidkahl's full-sized avatar
🏠
Working from home

Arvid Kahl arvidkahl

🏠
Working from home
View GitHub Profile
@btford
btford / chillax.md
Created October 30, 2014 06:59
Why you shouldn't worry so much about migrating with Angular

Several developers asked me about how difficult it will be to migrate Angular 1 to Angular 2. Angular 2 isn't done, so I legitimately have no idea how hard it will be. But there are a few high-level guiding principals in the design of Angular 1 that make adapting to changes like this fairly painless.

Angular 1 was designed so it would have a fairly minimal API surface. Let's look at controllers, since these are the meat of your app. Controllers are just functions that get passed other components as arguments:

MyController ($scope) {
  $scope.list = [];
  
  $scope.addItem = function (name) {
    $scope.list.push({
@robflaherty
robflaherty / gist:1129871
Created August 6, 2011 23:14
CoffeeScript and Stylus watch/build cakefile
# CoffeeScript and Stylus watch/build cakefile
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args...) ->
proc = spawn name, args
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.stdout.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) -> process.exit(1) if status isnt 0
@patrickarlt
patrickarlt / marker.js
Last active January 2, 2016 09:59
Custom marker with override.
// Subclass marker
var CustomMarker = L.Marker.extend({
// override the update function
update: function(){
//call the original update method
L.Marker.prototype.update.call(this);
// fire the update event
this.fire("update");
@michaeltchapman
michaeltchapman / gist:adf2eb593e619d1494f6
Created January 26, 2016 22:43
OpenStack as microservices
Openstack as microservices
--------------------------
One of the more promising experiments I did in the devops space in the last couple of years was supporting
microservices architectures in the way OpenStack is deployed and operated. The core design is that we have
consul running across all nodes as the initial or 'seed' service to establish cluster membership, and from
that base we can build everything we need. When data changes in consul, this triggers puppet runs on the
nodes that are subscribing to that data via consul_watch, and the updated data is sent in via hiera to be
realised on each node. This creates a feedback loop whereby services can be arbirtrarily distributed or
consolidated as needed depending on the deployment scenario.

My Elixir Deployment Wishlist

Foreward

Based on my recent experience of deployment, I've become rather frustrated with the deployment tooling in Elixir. This document is the result of me thinking to myself, "I wish we had x...". This document isn't meant to dishearten anyone who has built tooling for elixir - thank you so much for what you've done. This is meant more as what I personally see as something that would help a lot of Erlang/Elixir newbies like myself to be able to get deploying quickly and efficiently.

1. Release files should be templates

It should be possible to add in custom configuration to the bootstrap scripts. This would allow plugins to be able to add extra steps to the startup / shutdown / upgrade procedure. One way to implement this would be to make all scripts which handle bootstrapping or controlling the machine [.eex][1] templates. This would allow other parts of the release system to inject new functionality where needed.

@matteocrippa
matteocrippa / gist:5706448
Last active December 6, 2016 11:49
Node.js Upstart + Monit + Nodemon

UPSTART

sudo vi /etc/init/.conf

add inside:

description "<reponame>"
author "name"
@monostere0
monostere0 / GlobalEvents.js
Last active February 19, 2020 08:10
Fire events between different browser windows using localStorage.
(function(window){
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
_eventStack,
_findByName,
stackEvent,
removeEvent,
eventListener,
@arvidkahl
arvidkahl / puppeteer_demo.js
Created March 26, 2021 16:08
How to grab a high-res Tweet using Puppeteer
// using https://try-puppeteer.appspot.com/
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({width: 1500, height: 3000, deviceScaleFactor: 4});
await page.goto('https://twitter.com/arvidkahl/status/1375476092853743621?s=20');
await page.waitForNavigation({ waitUntil: 'networkidle2' })
console.log(await page.content());
await page.screenshot({path: 'screenshot.png'});
@arvidkahl
arvidkahl / README.md
Last active July 3, 2021 11:46
Twitter Giveaway bash+js script

This is a script picking winners for a contest where:

  • every winning entry has to mention one other twitter account in a reply
  • double winners are allowed

You'll need a few things installed:

  • jq
  • twarc
  • boxes
@thelinuxlich
thelinuxlich / unload.js
Created November 23, 2015 18:47
Function for executing logic when closing the page/tab or navigating away
var addUnloadEvent = function(unloadEvent, device) {
// device is a object containing parsed user-agent information
var executed = false,
exec = function() {
if (!executed) {
executed = true;
unloadEvent();
}