Skip to content

Instantly share code, notes, and snippets.

View jakubkulhan's full-sized avatar

Jakub Kulhan jakubkulhan

View GitHub Profile
@jakubkulhan
jakubkulhan / migrations.txt
Created May 4, 2018 05:01
List of database migration tools
- https://nextras.org/migrations/docs/3.0/
- https://phinx.org/
- https://www.liquibase.org/
- https://flywaydb.org/
- https://github.com/weavejester/ragtime (Clojure)
- http://knexjs.org/#Installation-migrations (Node.JS)
- https://github.com/lulco/phoenix
- http://taco-beru.name/schema-manage/
@jakubkulhan
jakubkulhan / chrome-devtools-protocol-screenshot.php
Last active January 16, 2018 09:31
Capture screenshots of the webpage loaded into a running Chrome instance using https://github.com/jakubkulhan/chrome-devtools-protocol
<?php
use ChromeDevtoolsProtocol\Context;
use ChromeDevtoolsProtocol\Instance\Instance;
use ChromeDevtoolsProtocol\Model\Page\CaptureScreenshotRequest;
use ChromeDevtoolsProtocol\Model\Page\NavigateRequest;
use ChromeDevtoolsProtocol\Model\Page\SetDeviceMetricsOverrideRequest;
$url = "...";
$ctx = Context::withTimeout(Context::background(), 30);
@jakubkulhan
jakubkulhan / main.go
Created January 8, 2018 22:19 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
import java.security.SecureRandom;
public class RandomString {
private static final String ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
private static final SecureRandom RANDOM = new SecureRandom();
/**
* Generates random string of given length from Base65 alphabet (numbers, lowercase letters, uppercase letters).
*
* @param count length
package com.example;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.reflections.Reflections;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Method;
@jakubkulhan
jakubkulhan / package.json
Last active February 28, 2016 10:28
Base package.json + webpack.config.js
{
"devDependencies": {
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"assets-webpack-plugin": "^3.3.0",
"babel-loader": "^6.2.2",
"babel-plugin-syntax-object-rest-spread": "^6.5.0",
"babel-plugin-transform-object-rest-spread": "^6.5.0",
"babel-polyfill": "^6.5.0",
// Stateful mixin is default implementation for components with state() method.
// It is intended to be used as decorator.
export function Stateful(klass) {
if (typeof klass === "function") {
Stateful.prototype.getOwnPropertyNames().forEach(function (methodName) {
Object.defineProperty(klass.prototype, methodName, {value: Stateful.prototype[methodName]});
});
return klass;
}
@jakubkulhan
jakubkulhan / WaitGroup.js
Created January 25, 2016 18:41
WaitGroup.js
class WaitGroup {
constructor() {
this.pending = 0;
this.values = [];
this.promise = Promise.resolve(this.values);
}
add(promise) {
if (this.pending <= 0) {
@jakubkulhan
jakubkulhan / jooq-java8.java
Last active January 20, 2016 19:35
jOOQ (http://www.jooq.org/) + Java 8 Rulez! = type-safe queries, shared behavior using traits
public interface RepositoryTrait<TABLE extends TableImpl<RECORD>, RECORD extends Record, POJO> {
DSLContext db();
TABLE table();
}
public interface UpsertRepositoryTrait<TABLE extends TableImpl<RECORD>, RECORD extends Record, POJO> extends RepositoryTrait<TABLE, RECORD, POJO> {
default int upsert(List<POJO> items) {
if (items.size() < 1) {
return 0;
}
@jakubkulhan
jakubkulhan / react-stdio.md
Last active January 7, 2016 20:57
react-stdio's deficiencies

react-stdio's deficiencies (from tweet):

1. de-/serialization from/to JSON

JSON is a great format to send to the browser because it's so widely supported. However, on the server-side, it is quite unnecessary verbose and requires push-down automaton to parse. Some formats build on JSON data model (Msgpack, BSON) and provide binary (de-)serialization, i.e. less bytes has to be serialized, less sent, less read, they will be faster, they would be more suited for this use case. Also on the server, more bytes sent might not be the worst thing, so formats like FlatBuffers or Cap'n'Proto would be probably the best performance-wise. JSON cannot represent directed acyclic graphs (I would say data underlying most UIs are DAGs), only trees. To transfer less data some kind of normalization (as [JSONGraph