Skip to content

Instantly share code, notes, and snippets.

View klepsydra's full-sized avatar

Marcos Koby klepsydra

  • US
View GitHub Profile
@mikiobraun
mikiobraun / autoreload.rb
Created January 15, 2010 15:14
autoreloading of ruby files which have changed in the meantime
# This file extends the Kernel's require function and adds the
# AutoReload module which allows to reload files once they have changed
# on the disk.
#
# Basically, you just require your files as usual, and if you want to update
# the files, either call AutoReload.reload(file) or AutoReload.reload_all.
#
# Usage:
# irb -rautoload
#
@abarringer
abarringer / gist:846621
Created February 27, 2011 22:24
Convert XML to SQLite
require 'rubygems'
require 'sqlite3'
require 'rexml/document'
include REXML
xml =<<XML
<records>
<entry><name>abc</name><qty>3</qty></entry>
<entry><name>def</name><qty>5</qty></entry>
<entry><name>ghi</name><qty>2</qty></entry>
@himynameisjonas
himynameisjonas / kittens.js
Created March 1, 2011 06:48
replace all images with kittens
jQuery("body").find('img').each(function(i,img) {
var w = img.width;
var h = img.height;
if (w && h) {
var src = 'http://placekitten.com/'+w+'/'+h;
img.src = src;
}
});
// code from https://github.com/lsemel/jquery-placekitten
@murphyslaw
murphyslaw / CSV Duplication Remover
Created May 28, 2011 07:49
A ruby script that removes duplicate rows in a csv file. Duplicates are found based on an identifier column and a criteria column, which are configurable.
#!/usr/bin/ruby -w
require 'csv'
require 'active_support/core_ext'
class Parser
attr_accessor :input_folder
attr_accessor :output_folder
attr_accessor :filename
@andris9
andris9 / git-cache-meta.sh
Created March 5, 2012 13:15
git-cache-meta
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9
@klepsydra
klepsydra / gist:2286570
Created April 2, 2012 19:29
triglist.GPW.txt
BUY WARFAMA 20120327 1.52 18.57923 2595257 lastprice=1.67 targetprice=1.35 quantity>=569.80
BUY TRAKCJA 20120323 1.21 18.40000 7787679 lastprice=1.16 targetprice=.94 quantity>=818.32
BUY DSS 20120322 4.62 18.39286 1250754 lastprice=3.70 targetprice=3.01 quantity>=255.55
BUY ABMSOLID 20120330 3.20 18.36735 3341862 lastprice=3.14 targetprice=2.56 quantity>=300.48
BUY BIOTON 20120329 0.10 18.18182 1713404 lastprice=0.09 targetprice=.07 quantity>=10989.00
BUY CIECH 20120320 16.45 12.26667 6342807 lastprice=16.65 targetprice=14.60 quantity>=52.68
BUY SKOTAN 20120319 3.03 11.38462 5863662 lastprice=3.57 targetprice=3.16 quantity>=243.42
BUY OVOSTAR 20120328 111.90 10 1003295 lastprice=109.20 targetprice=98.28 quantity>=7.82
BUY MIDAS 20120321 0.90 8.33333 11032438 last
@klepsydra
klepsydra / ST.50209607.statsTable.txt
Created April 2, 2012 19:45
ST.50209607.statsTable.txt
+----------------+---------------+---------------+---------------+
| Performance of Scottrade_50209607, 2012-04-02T00:24:33+02:00 |
+----------------+---------------+---------------+---------------+
|group |Unrealized |Realized |Combined |
+----------------+---------------+---------------+---------------+
| openValueSum | 2347.31 | 3056.22 | 1865.23 |
| closeValueSum | 2365.24 | 3132.37 | 1883.16 |
| gainLossRaw | 17.93 | 76.15 | 94.08 |
| profitSum | 17.93 | 76.15 | 94.08 |
| gainLossPerc | 0.76 | 2.49 | 5.04 |
@subelsky
subelsky / casperjs_example.js
Created August 8, 2012 18:51
Webscraping with CasperJS, PhantomJS, jQuery, and XPath
var system = require('system');
if (system.args.length < 5) {
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code.");
phantom.exit();
}
var account = system.args[1];
var username = system.args[2];
var password = system.args[3];
@johntyree
johntyree / getBlockLists.sh
Last active June 4, 2024 12:30
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
anonymous
anonymous / gist:4169393
Created November 29, 2012 14:19
Patched ruby psych to handle multiline regexp
module Psych
module Visitors
class ToRuby < Psych::Visitors::Visitor
def deserialize o
if klass = Psych.load_tags[o.tag]
instance = klass.allocate
if instance.respond_to?(:init_with)
coder = Psych::Coder.new(o.tag)
coder.scalar = o.value