Skip to content

Instantly share code, notes, and snippets.

View akullpp's full-sized avatar

aku akullpp

View GitHub Profile
export default xs => {
if (!Array.isArray(xs)) {
throw new ValidationError(
`Argument must be of Array-type, was ${typeof xs}`,
)
}
return flatten(xs)
}
class ValidationError extends Error {
@akullpp
akullpp / license.js
Created November 3, 2017 12:53
Get license for all repos of a user via nodejs and GitHub v3 API
const https = require('https')
const USER = 'akullpp'
const OPTIONS = {
method: 'GET',
host: 'api.github.com',
headers: {
'Accept': 'application/json',
'User-Agent': USER,
@akullpp
akullpp / gist:1a04c8dc11447952d8aff803ba8803b6
Created October 12, 2017 09:14
Get all repositories from stash
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import stashy
from sys import argv
stash = stashy.connect('url', 'username', 'password')
def getProjects():
projects = {}
@akullpp
akullpp / uprade.md
Last active July 27, 2017 09:06
Major A/B Upgrade

Backwards incompatible change to the persistence

Backwards incompatible changes to persistence always require at least two upgrade steps to encapsulate migration without causing downtime.

The REST service has a new required field

  1. Create a new REST service artifact "B" which creates the field and treats it as optional in read operations but required in write operations with an incremented minor version.
  2. Create a migration artifact (or include migration in the artifact from step 1) which populates the field. A/B deploy "B".
  3. Create a new REST service artifact "C" which treats the field as required with an incremented minor version.
  4. Wait until the migration is complete, then A/B deploy C.
// diff-so-fancy
npm install -g diff-so-fancy && git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
// git status abbreviation
git config --global alias.st 'status'
// git add, amend and force push
git config --global alias.ap '!git add . && git commit --amend --no-edit && git push -f'
// git delete branches merged to develop
@akullpp
akullpp / highlight.scss
Created September 25, 2016 13:47
Jekyll Syntax Highlighter in SCSS
.highlight {
.c, .cm, .c1, .cs {
color: #408080;
}
.k, .kc, .kd, .kn, .kp, .kr, .sx, .bp, .nt, .nb {
color: #008000;
}
.o, .m, .mf, .mh, .mi, .mo, .il {
color: #666666;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akullpp
akullpp / alexa500.js
Last active March 12, 2017 20:07
nightmare: Alexa Top 500
'use strict';
// http://www.nightmarejs.org/
var Nightmare = require('nightmare');
var nightmare = Nightmare();
var pages = Array.from({length:20}, (_, k) => (k));
var top500 = [];
getTop500(pages);
@akullpp
akullpp / gist:469bd1c89308a5e7c0bd
Created January 7, 2015 09:47
Bower overwrites
You can overwrite certain attributes of a bower.json, e.g. the "main"-attribute with:
"overrides" : {
"lodash": {
"main": "lodash.js:
}
}
@akullpp
akullpp / gist:b37acbe7cd6e40f282c9
Last active August 29, 2015 14:11
Extract WordPress posts from MySQL

Step 1: Import SQL backup:

mysql -u root wp_dump < backup.sql

Step 2: Login:

mysql -u root

Step 3: Use database: