Skip to content

Instantly share code, notes, and snippets.

View akullpp's full-sized avatar

aku akullpp

View GitHub Profile
@akullpp
akullpp / gist:660f2b4234053556e4a4
Created September 24, 2014 11:27
Good default colors for the web
RED #FF4136
GREEN #2ECC40
BLUE #0074D9
WHITE #FFFFFF
BLACK #111111
GRAY #AAAAAA
SILVER #DDDDDD
@akullpp
akullpp / gist:99f8ca513ca5cdda570a
Last active August 29, 2015 14:06
Ways to instantiate a class in Java
public class A {
public void initializer() {
B b1 = new B();
B b2 = (B) classloaders.A.class.getClassLoader().loadClass("B").newInstance();
B b3 = (B) Class.forName("B").newInstance();
}
}
@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:

@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 / 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);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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;
}
// 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 / 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.
@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 = {}