Skip to content

Instantly share code, notes, and snippets.

View zakjan's full-sized avatar

Jan Žák zakjan

View GitHub Profile
@zakjan
zakjan / toSource.js
Last active December 25, 2015 16:19
Object.toSource
var toSource = function (value) {
function show (value) {
if (_.isUndefined(value)) {
value = "undefined";
} else if (_.isFunction(value)) {
value = "" + value;
var indentMatches = value.match(/^ +/mg);
if (!_.isEmpty(indentMatches)) {
var indentSize = Math.min.apply(null, _.map(indentMatches, function (x) { return x.length; }));
value = value.replace(new RegExp("^ {" + indentSize + "}", "mg"), "");
@zakjan
zakjan / cryptoHelpers.coffee
Last active June 26, 2021 08:29
Encryption in NodeJS
###*
* Encryption:
*
* cipher: AES-128-CBC
* key: 16 bytes
* IV: 16 bytes, random, non-reused, prepended to cipher text
* padding: PKCS#7
###
crypto = require 'crypto'
@zakjan
zakjan / keybase.md
Created October 26, 2014 10:37
keybase.md

Keybase proof

I hereby claim:

  • I am zakjan on github.
  • I am zakjan (https://keybase.io/zakjan) on keybase.
  • I have a public key whose fingerprint is 83B0 CA96 CFAE 61FA 67EC 92B6 CC20 463E 3A26 C108

To claim this, I am signing this object:

@zakjan
zakjan / phpci.sh
Last active August 29, 2015 14:25
PHPCI init script
#!/bin/sh
NAME=phpci
PIDFILE=/var/run/${NAME}.pid
DAEMON=/home/www/ci.d.cdn77.com/subdomains/www/phpci/daemonise
DAEMON_OPTS=phpci:daemonise
do_start() {
echo -n "Starting daemon $NAME... "
@zakjan
zakjan / README.md
Last active November 19, 2015 14:30
TeamCity init scripts

TeamCity init scripts

Install: update-rc.d <job> defaults

Uninstall: update-rc.d <job> remove

Start: /etc/init.d/<job> start

Stop: /etc/init.d/<job> stop

[user]
name = Jan Zak
email = zj@zakjan.cz
[core]
editor = vim
[color]
ui = true
[pull]
rebase = true
[push]

HTTP methods

HTTP methods indicate the desired action to be performed on the identified resource.

Method Idempotent Safe Body
GET yes yes no
SEARCH (proposed) yes yes yes
POST no no yes
PUT yes no yes
@zakjan
zakjan / dashing.sh
Last active November 19, 2015 14:30
Dashing init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: dashing
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
USER=dashing
@zakjan
zakjan / app.html
Created November 23, 2016 05:50
Aurelia Gist
<template>
<require from="./item"></require>
<h1>${message}</h1>
<ul>
<li repeat.for="item of items">
${item}:
<item item.bind="item" click-handler.bind="itemClicked" title="itemClicked"></item>
<item item.bind="item" click-handler.bind="itemClicked.bind($this)" title="itemClicked.bind($this)"></item>
<item item.bind="item" click-handler.bind="itemClickedBound" title="itemClickedBound"></item>
@zakjan
zakjan / app.html
Last active November 23, 2016 06:28
Aurelia Gist
<template>
<require from="./item"></require>
<h1>${message}</h1>
<ul>
<li repeat.for="item of items">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.bind="matcher">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.bind="matcher.bind($this)">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.bind="matcherBound">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.call="matcherBound(item1, item2)">