Skip to content

Instantly share code, notes, and snippets.

View meddulla's full-sized avatar

Sofia meddulla

  • Cloudflare
  • Portugal
View GitHub Profile
@meddulla
meddulla / downloadplaylistwithcurl.py
Created January 3, 2010 18:35
download m3u playlist with curl
# see http://wiki.alcidesfonseca.com/blog/casual-programming/
# if no wget (as in mac 10.3) curl can be used
import os
for line in open("index.m3u"):
os.system("curl -O %s" % line)
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
# Commonly used webrat steps
# http://github.com/brynary/webrat
Given /^Debug$/ do
puts response_body
filepath = '/tmp/webrat_debug.html'
File.open(filepath, "w") do |file|
#!/bin/sh
# Run all cucumber tests in app cucumber/features directory every n seconds
# Usage
# ./autotest.sh <loop time seconds>
# ./autotest.sh 15
# assumes test is in cucumber/features
# and cucumber dir in same dir as this file
check() {
# see http://www.theautomatedtester.co.uk/seleniumtraining/selenium_rc_setup.htm
# java -jar selenium-server.jar -htmlSuite *firefox <start URL> <name of the file you load into the IDE> <file you want to save the results in>
java -jar selenium-server.jar -htmlsuite *firefox http://www.theautomatedtester.co.uk /Applications/MAMP/htdocs/selenium-remote-control-1/examples/testsuite/testsuite.html /Applications/MAMP/htdocs/selenium-remote-control-1/examples/testsuite/results.html
+-------+ 1 0..* +-------+
| Class | ---------> | Style |
+-------+ +-------+
+-------+ 1 1 +-----------+
| Class | <---------> | HashTable |
+-------+ | -- |
| metadata |
+-----------+
@meddulla
meddulla / server.js
Created April 5, 2011 18:00
using node to display realtime heatmap of user's clicks
var sys = require('sys'),
fs = require('fs'),
Url = require('url'),
http = require('http'),
querystring = require('querystring');
//create a Heatmap Obj that inherits
//from EventEmitter
var events = require('events');
//responds to request when new click is sent
//to /addDataPoint, otherwise hangs
var displayNewDataPoints = function(req, res) {
MyHeatmap.on('added', function(dt) {
//print client side js so client heatmap
//display functions are called
//and recall this url again
var str = 'xx.addDataPoint('+dt.x+","+dt.y+');';
str += 'ajad_send(nurl);';
res.write(str,'utf8');
@meddulla
meddulla / .htaccess
Created April 11, 2011 16:36
fix http auth when php as cgi
#fix httpauth when php as cgi
RewriteCond %{HTTP:Authorization} ^Basic.*
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1?Authorization=%{HTTP:Authorization} [L,QSA]
@meddulla
meddulla / JE.js
Created May 11, 2011 10:44
js simple mvc
if (typeof JE === 'undefined') {
JE = {};
}
/*
* Usage:
* agenda = JE.events.controller.init();
* Controller inits events, gets data from model, model on success updates view
*/
JE.events = (function() {
// Create closure
@meddulla
meddulla / infinite_scroll.js
Created May 12, 2011 15:17
simple infinite scrolling
//detect when user has scrolled to end of content
//that is to be loaded using an infinite scroll pattern
//no need for plugin
$(window).scroll(function(){
var bottomList = $("#item_at_bottom_of_list");
var viewTop = $( window ).scrollTop();
var viewBottom = (viewTop + $( window ).height());
var absoluteBottomList = Math.floor(bottomList.offset().top + bottomList.height());
var scrollBuffer = 150;
if ((absoluteBottomList - scrollBuffer) <= viewBottom){