Skip to content

Instantly share code, notes, and snippets.

View mishak87's full-sized avatar

Michal Gebauer mishak87

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1Q8pg93Nu7XCnu5svsXfzRHhSZjDY4cHsm https://explorer.blockstack.org/address/1Q8pg93Nu7XCnu5svsXfzRHhSZjDY4cHsm
@mishak87
mishak87 / init.coffee
Last active May 20, 2016 09:53
Atom.io Memleak - reload when free memory is less or equal 5 % ~/.atom/init.coffee
os = require('os')
window.setInterval (->
free = Math.round((os.freemem() / os.totalmem()) * 100)
console.log 'Free memory: ' + free + ' %'
if free <= 5
atom.reload()
return
), 60 * 1000
@mishak87
mishak87 / README.md
Last active April 25, 2016 09:35
Open Go GVM projects and others in Atom

Assuming that projects are organized like this ~/workspace[/<group>[/<vendor>]]/<project>.

Project acme/api is written in Go. It will open atom with all projects and env set for acme/api.

project acme/{api,web} todo
@mishak87
mishak87 / migrations.sh
Created April 24, 2016 20:29
Simple migration script (/bin/sh)
#!/bin/sh
set -eu
readonly psqlOptions="-h postgres postgres postgres"
initdb () {
psql $psqlOptions -q -c "CREATE TABLE IF NOT EXISTS __version (id integer PRIMARY KEY, value varchar(255));"
psql $psqlOptions -q -c "INSERT INTO __version VALUES (1, '') ON CONFLICT DO NOTHING"
}
# docker build && docker run
dbr () {
id=$(docker build . | grep 'Successfully built' | cut -d' ' -f 3)
if [ $? -ne 0 ]; then
exit 1;
fi
docker run "$id" "${@}"
}
@mishak87
mishak87 / copy-repo.sh
Last active October 20, 2015 09:29
Copy repository ie. from gitosis to gitlab
#!/bin/bash
dir=$(mktemp -d)
old=$1
new=$2
git clone "$old" "$dir"
cd "$dir"
git remote add new "$new"
git push -u new master
@mishak87
mishak87 / Dockerfile
Created October 5, 2015 14:04
Docker image for Adminer.org
FROM php:5.6-apache
ENV ADMINER_VERSION=4.2.2
RUN apt-get update && apt-get install -y \
libpq-dev \
&& docker-php-ext-install pgsql
RUN curl -LSs https://www.adminer.org/static/download/$ADMINER_VERSION/adminer-$ADMINER_VERSION.php > /var/www/html/index.php \
&& rm /var/www/html/index.html
@mishak87
mishak87 / elastic-mapping-matrix.js
Created July 16, 2015 09:57
Generates CSV bool matrix with true where type has field from ElasticSearch /storage/_mappings
var x = /* elastic mapping */ {};
var mappings = x.storage.mappings;
var map = {};
for (var i in mappings) {
var k = Object.keys(mappings[i].properties);
for (l = 0; l < k.length; l++) {
map[k[l]] = {};
}
}
for (var i in mappings) {
@mishak87
mishak87 / latte.php
Created July 9, 2015 13:07
Debug Latte output
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
echo (new Latte\Engine)
->setLoader(new Latte\Loaders\StringLoader)
->compile(file_get_contents('php://stdin'));
@mishak87
mishak87 / go-lang-vanity-imports.conf
Created April 12, 2015 20:26
nginx vanity imports for go(lang)
location ~ /(?<namespace>[a-z][a-z0-9]*)/(?<package>[a-z][a-z0-9]*) {
if ($args = "go-get=1") {
add_header Content-Type text/html;
return 200 '<meta name="go-import" content="$host/$namespace/$package git https://git.$host/$namespace/$package">';
}
}