Skip to content

Instantly share code, notes, and snippets.

View avioli's full-sized avatar

Evo Stamatov avioli

View GitHub Profile
@avioli
avioli / gist:1387894
Created November 23, 2011 04:27
Simple Pinger
# ping.txt is exactly 100 bytes
pinger = (callback, file_to_ping) ->
ajax = start = done = null;
ajax = if window.XMLHttpRequest then (new XMLHttpRequest()) else (new ActiveXObject('MSXML2.XMLHTTP.3.0'))
if !ajax
return callback?.call null, 0
start = new Date()
ajax.onreadystatechange = ->
if ajax.readyState > 0
@avioli
avioli / more.md
Created May 2, 2012 00:08 — forked from vasilisvg/more.md
This is my backup script which syncs my server to my dropbox every day.

The script below is triggered every day from my Mac. I use Hazel to move the tar.gz to an external hard disk once it's finished. This happens every day without me noticing.

You should have a similar script.

@avioli
avioli / valid-html5-markup.html
Created October 11, 2012 23:09
Valid HTML5 markup
<!DOCTYPE html>
<title>Saving money, saving bytes</title>
<meta charset="utf-8">
<table>
<thead>
<tr>
<th scope="col">Income
<th scope="col">Taxes
<tbody>
<tr>
@avioli
avioli / mkvtoolnix-10.8.2.txt
Created December 7, 2012 10:46
brew install -vd mkvtoolnix # on OS X 10.8.2
$ brew install -vd mkvtoolnix
/usr/local/bin/brew: loading /usr/local/Library/Formula/mkvtoolnix.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/boost149.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/libvorbis.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/xz.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/pkg-config.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/libogg.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/libmatroska.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/libebml.rb
/usr/local/bin/brew: loading /usr/local/Library/Formula/flac.rb
@avioli
avioli / autolayout_trace
Created March 26, 2013 15:45
A debugger trace command for XCode's Auto Layout
po [[UIWindow keyWindow] _autolayoutTrace]
avioli:chef-repo(master) $ knife bootstrap localhost --ssh-user vagrant --ssh-password vagrant --ssh-port 2222 --run-list "recipe[apt],recipe[aliases],recipe[apache2],recipe[networking_basic]" --sudo
Bootstrapping Chef on localhost
localhost Starting Chef Client, version 11.4.4
localhost resolving cookbooks for run list: ["apt", "aliases", "apache2", "networking_basic"]
localhost Synchronizing Cookbooks:
localhost - networking_basic
localhost - apt
localhost - aliases
localhost - apache2
localhost - magic_shell
@avioli
avioli / plot-a-dot-on-map.m
Created September 12, 2013 00:21
When you've got a CLLocationCoordinate2D coordinate and want to plot a dot on a image of a map that you know its NW and SE coordinates. In my case the image is 100x100px.
CLLocationCoordinate2D sightingLocation = CLLocationCoordinate2DMake([self.sighting.locationLat floatValue], [self.sighting.locationLng floatValue]);
// Australia's map coordinates
CLLocationCoordinate2D nw, se;
nw = CLLocationCoordinate2DMake(-7.410849283839832, 112.41210912499992);
se = CLLocationCoordinate2DMake(-44.248667520681586, 154.07226537499992);
MKMapPoint topLeftPoint = MKMapPointForCoordinate(nw);
MKMapPoint bottomRightPoint = MKMapPointForCoordinate(se);
MKMapRect mapRect = MKMapRectMake(topLeftPoint.x, topLeftPoint.y, bottomRightPoint.x - topLeftPoint.x, bottomRightPoint.y - topLeftPoint.y);
<?php
# add to your wp-config.php, ANYWHERE before "require_once(ABSPATH . 'wp-settings.php');" line
# you can drop the :8080 if you serve it on the regular port
# change <your.old.domain.com> to your domain you wish to replace
define('WP_HOME', 'http://localhost:8080');
define('WP_SITEURL', 'http://localhost:8080');
function _fix_siteurl_in_html( $buf = '' ) {
$buf = str_replace( 'http://<your.old.domain.com>/', WP_SITEURL . '/', $buf );
return $buf;
# requires imagemagick and ffmpeg (tested with latest versions)
# make sure you set an INFILE variable first
# get GIF info
video=$(ffmpeg -i "$INFILE" 2>&1 /dev/null | grep "Video:");
# get GIF Frames per second
fps=$(echo "$video" | sed -n "s/.* \([0-9.]*\) fps.*/\1/p");
# a convinience variable so we can easily set FPS on the video
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Text Switcher</title>
<style>
@-webkit-keyframes blink {
from, to { border-color: transparent; }
50% { border-color: red; }
}