Skip to content

Instantly share code, notes, and snippets.

View endel's full-sized avatar

Endel Dreyer endel

View GitHub Profile
@endel
endel / redis-server-for-init.d-startup
Created June 16, 2011 03:16 — forked from lsbardel/redis-server-for-init.d-startup
Init.d Redis script for Ubuntu
#!/bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
mysqldump -u root -pYourPasword database table_name \
--compact --no-create-info | \
sed -r "s/\([0-9]*/\(NULL/g"
@endel
endel / okapi.md
Created June 26, 2011 13:57
Cool Okapi ASCII Art
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         __ <`-,-,_,-,      /                               \
                         \_;>   ^  _<---' <                                  |
                            )  _,-'         \                               /
                           /  /               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__                       ,'  /
)_\                  _,-'   /
   \_   _,-_-,_  _,-'      /
     \_/\,_ `  `'          \
      /\,_ `               |
@endel
endel / rm_svn.sh
Created July 27, 2011 21:18
Recursively remove .svn folders.
#!/bin/sh
echo "recursively removing .svn folders from"
pwd
rm -rf `find . -type d -name .svn`
@endel
endel / ensure_utf8.rb
Created August 2, 2011 03:30
Ensure UTF-8 string from any source with Ruby
require 'net/http'
url = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.start(url.host, url.port) {|http|
http.get(url.path)
}
valid_content = ensure_utf8(res.body)
@endel
endel / arial.as
Created August 3, 2011 01:53
Example: Embed limited font glyphs in ActionScript 3.0
package {
import flash.display.Sprite;
public class _Arial extends Sprite {
[Embed(source='C:/WINDOWS/Fonts/ARIAL.TTF', fontName='_Arial', unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
public static var _Arial:Class;
}
}
@saas_publisher = @saas_publishers.find(params[:id])
@saas_publisher.publisher.update_attributes(params[:saas_publisher].delete(:publisher))
@saas_publisher.update_attributes(params[:saas_publisher])
ruby zlib-compressor.rb input output
@endel
endel / hoptoad.rb
Created September 8, 2011 04:14 — forked from thibaudgg/hoptoad.rb
Custom Goliath Rack middleware for Toadhopper / HoptoadNotifier
require 'toadhopper'
require 'em-synchrony/em-http'
class Toadhopper
def post_document(document, headers={})
uri = URI.parse(@error_url)
begin
response = EM::HttpRequest.new(uri).post({
:body => document,
:head => {'Content-type' => 'text/xml', 'Accept' => 'text/xml, application/xml'}.merge(headers)
<script type="text/javascript">
var data="eWtmPzQ7NyhyZD83OihydWtmPzo2KHJ1Y2tmPzMyMjo0KHJrZj85OCh1ZWtmPzUodWV2aWtmPzQ3KGhvdj91c3djdGc%3D";
var options = {format : 'square', width : '300', height : '250'};
document.write('<scri' + 'pt src="http://display.ocapi.com.br/embed.js?url='+encodeURIComponent(parent.location.href)+'&data='+data+'&r='+Math.random()+'"></scri' + 'pt>');
</script>