Skip to content

Instantly share code, notes, and snippets.

Avatar

lex(a) mourek lexaurin

View GitHub Profile
View Bookmarklets
$$('video').forEach(v => v.playbackRate = 1.4)
@lexaurin
lexaurin / jessie-mongodb-3-3-x.sh
Last active Aug 27, 2016 — forked from hpherzog/jessie-mongodb-3-0-x.sh
Install mongodb version 3.3.x on debian jessie
View jessie-mongodb-3-3-x.sh
#!/bin/sh
apt-key adv --keyserver keyserver.ubuntu.com --recv A15703C6
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.3 main" | tee /etc/apt/sources.list.d/mongodb-org-3.3.list
apt-get update
#apt-get install -y mongodb-org
apt-get install -y mongodb-org-unstable
@lexaurin
lexaurin / formatSizeSI.js
Created Dec 16, 2015
Simple & elegant file size formatter
View formatSizeSI.js
#!/usr/bin/env node
require('v8').setFlagsFromString('--harmony_destructuring');
const assert = require('assert');
function formatSizeSI(size) {
var index = Math.floor(Math.log(Math.abs(size)) / Math.log(1000)) | 0;
return +(size / Math.pow(1000, index)).toPrecision(3) + ' '
+ (index ? 'kMGTPEZY'[--index] + 'B' : 'Bytes');
}
@lexaurin
lexaurin / redis-pipe-bug.php
Last active Aug 29, 2015
phpredis "errno=32 Broken pipe" bug
View redis-pipe-bug.php
<?php
$redis = new Redis();
var_dump($redis->connect('127.0.0.1'));
echo 'Parent pid: ' . getmypid() . PHP_EOL;
set_error_handler(function($errno, $errstr, $errfile, $errline) {
echo 'Error in PID ' . getmypid() . ': ' . $errstr . PHP_EOL;
});
View gist:8841425
phpunit --log-json php://stdout unit/ | awk '$NF ~ '/,/' && $1 ~ /"(test|time)"/' | cut -d: -f2- | sed "N;s/\n/--/" | sed "s/,//"| awk 'BEGIN{FS="--"}; {print $2 $1}' | sort -r | head -n 20
@lexaurin
lexaurin / .gitconfig
Last active Dec 11, 2015
How to manage changelog by git tags? Prefix tags with "v" letter and use this alias:
View .gitconfig
[alias]
changelog = "!git tag -l v* -n20 | sed -n 'H;${;g;s/\\n[^v]/\\x00/g;p}' | sort -rV | tr \\\\000 \\\\n | less"
@lexaurin
lexaurin / gist:943888
Created Apr 27, 2011
Shows actual git branch on command prompt
View gist:943888
#GIT bash by HABR
export PSORIG="$PS1"
function GITCHECK() {
STATUS=$(git status 2> /dev/null)
if [ -n "$STATUS" ] ; then
BRANCH="$(echo "$STATUS" | head -n1 | awk '{print $4}')"
export PS1=$PSORIG$(echo -en "\[\033[01;33m\]$BRANCH > \[\033[00m\]")
else
export PS1="$PSORIG"
@lexaurin
lexaurin / gist:943887
Created Apr 27, 2011
Shows actual git branch on command prompt
View gist:943887
#GIT bash by HABR
export PSORIG="$PS1"
function GITCHECK() {
STATUS=$(git status 2> /dev/null)
if [ -n "$STATUS" ] ; then
BRANCH="$(echo "$STATUS" | head -n1 | awk '{print $4}')"
export PS1=$PSORIG$(echo -en "\[\033[01;33m\]$BRANCH > \[\033[00m\]")
else
export PS1="$PSORIG"