Skip to content

Instantly share code, notes, and snippets.

View matiskay's full-sized avatar

Edgar Marca matiskay

View GitHub Profile
@matiskay
matiskay / get_redis_json.rb
Created December 29, 2011 16:41
Redis and json
require 'redis'
require 'json'
def get_redis_json()
FIELDS = ['title', 'desc', 'lat', 'lon']
json = {}
FIELDS.each do |field|
json[field] = redis.get("point:#{id}:#{field}")
@matiskay
matiskay / README.md
Created December 29, 2011 21:24 — forked from lenary/partials.rb
Partials on Sinatra + Haml

Partials on Sinatra + Haml

This is the haml version. If you want to use the same with erb just change haml to erb.

How to use it

  • Create you partial form example _form.haml (The underscore at the beginning is really important).
  • In you .haml file just write = partial("form").
@matiskay
matiskay / README.md
Created December 30, 2011 17:22
A basic sinatra Scaffold using Thor

Sinatra Scaffold

This a simple sinatra scaffold using Thor

How it works

$ thor sinatra:scaffold <app-name>
@matiskay
matiskay / README.md
Created December 30, 2011 18:20
Download jquery using Ruby

Download jquery using Ruby

There must be another way to do this, but this works for me.

I should use a gem. :)

Todo

  • Let's make a function with this. [DONE] I don't know how to cross text on markdown.
  • Let's make a class <-- A nice wrapper.
@matiskay
matiskay / feeds.php
Created January 2, 2012 21:03
Simple Pie Example
<?php
require_once('includes/vendor/simplepie/simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url( 'your.xml' );
//$feed->set_cache_location( $_SERVER['DOCUMENT_ROOT'] . '/includes/vendor/simplepie/cache' );
//@TODO: I use my root because I'm using a simbolic link. I have to really understand whot virtualhost works.
$feed->set_cache_location( 'Set your location' );
$feed->init();
$feed->handle_content_type();
?>
import re
class HTTPForcedBasicAuthHandler(HTTPBasicAuthHandler):
auth_header = 'Authorization'
rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+'
'realm=(["\'])(.*?)\\2', re.I)
def __init__(self, *args, **kwargs):
HTTPBasicAuthHandler.__init__(self, *args, **kwargs)
@matiskay
matiskay / README.md
Created January 4, 2012 02:41
Working with Drupal url
@matiskay
matiskay / README.md
Created January 4, 2012 03:31
Pretty json Using Ruby

Pretty json Using Ruby

This is a simple snippet to show how to work with json and ruby. This code is really messy. Sorry

TODO

  • Refactor this code.
  • Refactoring is welcome.
@matiskay
matiskay / README.md
Created January 4, 2012 16:59
Get the vocabulary id using the machine name
@matiskay
matiskay / Gemfile
Created January 4, 2012 17:54 — forked from vangberg/README
Deploying a Sinatra app to Heroku
source 'http://rubygems.org'
gem 'sinatra'
gem 'dm'