Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
lyoshenka / pretty_print_json.php
Created December 11, 2013 15:39
Pretty print JSON
<?php
// https://github.com/GerHobbelt/nicejson-php/blob/master/nicejson.php
// original code: http://www.daveperrett.com/articles/2008/03/11/format-json-with-php/
// adapted to allow native functionality in php version >= 5.4.0
/**
* Format a flat JSON string to make it more human-readable
*
@lyoshenka
lyoshenka / search-git-history.md
Last active April 1, 2025 07:51
Search Git commit history for a string and see the diffs

Searching Git commit history

This should be one of the core features of Git, but for some reason it's impossible to figure out how to search for a string in your commit history and see the diffs that that string is in. Here's the best I've come up with:

To find which commits and which files a string was added or removed in:

git log -S'search string' --oneline --name-status

To see the diff of that

<?php
$options = [
'max_delta' => 0.01, // if percent change in scores falls below this, assume the scores are stable
'max_victory_ratio' => 1.5, // cap the margin of victory of an individual game at this ratio
];
protected static function computeRRIInternal($games, $teamsByTeamProxy, $options)
{
$delta = 1; // percent change in scores since last round
// based on this tweet: https://twitter.com/g_marty/status/6714909630926848
// jQuery must be loaded
// if it's not, use this: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet/
// run the code below, then click any element you want. that element and all of its z-indexed ancestors are printed to the console
(function() {
$('*').off(); // optional. use this if other js events are blocking propagation
@lyoshenka
lyoshenka / whiteboard_clean.sh
Last active January 4, 2016 21:09
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
#!/bin/bash
convert $1 -resize %50 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2
# source: http://www.reddit.com/r/commandline/comments/1weqnn/cli_oneliner_script_to_clean_up_and_beautify/
@lyoshenka
lyoshenka / git_for_marge.md
Last active August 29, 2015 13:55
Git for marge
  1. ssh -t [email protected] "cd topscore; bash" - connect to server

  2. git fetch && git merge origin/master - get latest changes

  3. git add -A && git commit -m "message goes here" - commit changes

  4. git push - push changes

  5. ./symfony fs:snapshot s3 - load the latest database snapshot

Backtick.io - Save to Pinboard

MIME-Version: 1.0
Received: by 10.114.61.203 with HTTP; Wed, 5 Feb 2014 14:03:44 -0800 (PST)
Date: Wed, 5 Feb 2014 17:03:44 -0500
Delivered-To: REDACTED
Message-ID: <CAKko9b2cUKCDQaSJaJ930SOCe_88_0CQH6FU5_ZFm2qzk_pYtQ@mail.gmail.com>
Subject: image test
From: REDACTED
To: REDAcTED
Content-Type: multipart/related; boundary=14dae93d8c5e2a262104f1afee0f
@lyoshenka
lyoshenka / daemonize_anything.sh
Last active August 29, 2015 13:56 — forked from Radamanf/Ghost - Demonize anything
Turn any command into a daemon. Use this as an init.d script.
#!/bin/bash
# Licence: GPLv3, MIT, BSD, Apache or whatever you prefer; FREE to use, modify, copy, no obligations
# Description: Bash Script to Start the process with NOHUP and & - in background, pretend to be a Daemon
# Author: Andrew Bikadorov
# Script v1.5
# For debugging purposes uncomment next line
#set -x
@lyoshenka
lyoshenka / chicken.sh
Last active August 29, 2015 13:56
My simple timer to alert me when the chicken's ready to take out of the oven.
#!/bin/bash
FILENAME=$(basename "$0")
PID=$(pgrep -o "$FILENAME")
if [ "$1" = "-k" ]; then
MIN=$(ps -o start= -o cmd= -p "$PID" | cut -d' ' -f4)
if [[ "$MIN" =~ ^-?[0-9]+$ ]]; then
echo "Killing timer"
kill -9 "$PID"