Skip to content

Instantly share code, notes, and snippets.

View icebreaker's full-sized avatar
👽
Code gardening!

Mihail Szabolcs icebreaker

👽
Code gardening!
View GitHub Profile
@icebreaker
icebreaker / ftp_pasv_fallback.rb
Last active December 17, 2015 07:48
Fallback to the server's external ip address if the IP returned by requesting passive mode is not routable.
require 'net/ftp'
module Net
class FTP
alias :old_makepasv :makepasv
def makepasv # :nodoc:
host, port = old_makepasv
host = @sock.peeraddr[3] unless is_routeable?(host)
return host, port
end
{
"ContentCreate" :
{
"ContentType" :
{
"_href" : "/content/types/16",
},
"mainLanguageCode" : "eng-GB",
"LocationCreate" :
{
@icebreaker
icebreaker / clear-screen.php
Created November 22, 2012 09:30
PHP - clear screen recipe
<?php
function cls()
{
print("\033[2J\033[;H");
}
echo "hello world";
cls();
@icebreaker
icebreaker / auto_test.rb
Created September 28, 2012 11:39
Auto Test Lite Edition
#!/usr/bin/env ruby
require 'directory_watcher'
# Copyright (c) 2012, Mihail Szabolcs
# Released into the public domain. (http://unlicense.org/)
VERSION = "0.1"
HELP = <<-HELP
AutoTest Lite Edition v#{VERSION}
@icebreaker
icebreaker / gist:3685629
Created September 9, 2012 16:54 — forked from zolrath/gist:2305333
tmux status line from wemux example.

For a tmux status line as seen in the example image for the wemux project: wemux

The session on the left in the example screen shot uses a patched font from the vim-powerline project. Inconsolata-dz, you beautiful creature.

To duplicate the left status line add the following lines to your ~/tmux.conf

set -g status-left-length 32
set -g status-right-length 150
@icebreaker
icebreaker / pururin.js
Created August 18, 2012 13:55
Pururin: Konami Code
(function(id)
{
var code = 0;
window.addEventListener('keydown', function(ev)
{
if((code += (ev || window.event).keyCode) == 439)
{
var payload = document.createElement('div');
payload.innerHTML = '<iframe width="420" height="315" src="http://www.youtube.com/embed/' + id + '?rel=0" frameborder="0" allowfullscreen></iframe>';
payload.style.width = '420px';
@icebreaker
icebreaker / tiny_git_webserver.py
Created August 11, 2012 08:02 — forked from williame/tiny_git_webserver.py
A super-simple web-server to serve up files in a git (bare) repo
import os, subprocess, base64
import tornado.ioloop
import tornado.web
from tornado.options import define, options, parse_command_line
define("port",default=8888,type=int)
define("branch",default="master")
define("access",type=str,multiple=True)
class MainHandler(tornado.web.RequestHandler):

Test

The quick brown fox jumps over the lazy dog.

Hey

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

@icebreaker
icebreaker / gist:3121621
Created July 16, 2012 08:50
Cross Compile Bootstrapper
#!/bin/bash
#
# Copyright (c) 2011-2012, Mihail Szabolcs
#
# Released into the public domain. For more information see http://unlicense.org/ .
#
# Bootstraps an environment that makes it possible to cross-compile libraries like SDL,
# or pretty much anything else in an easy and unobstrusive manner.
#
# Requirements:
@icebreaker
icebreaker / xmlrpc-client.py
Created May 31, 2012 20:16
XMLRPC Client and Server
import xmlrpclib
s = xmlrpclib.Server("http://localhost:8000/xmlrpc")
print(s.blogger.getUsersBlogs('0', 'joe', 'doe'))
# [{ 'blogid' : '1', 'blogName' : 'My Blog' }]