Skip to content

Instantly share code, notes, and snippets.

@frnz
frnz / strope_facebook.js
Created January 13, 2012 13:54
strope facebook.js
<html>
<head>
<title>XMPP with JavaScript</title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
<script src='strophe.js'></script>
<script>
var BOSH_SERVICE = 'http://nodebosh.herokuapp.com';
var connection = null;
@frnz
frnz / string_calculator.rb
Created June 20, 2011 03:09
String calculator
module StringCalculator
def add
return 0 if empty?
raise "Negatives not allowed: #{ negative_numbers.join(",") }" unless negative_numbers.empty?
retrieve_numbers.reduce(0) {|total,number|total+number}
end
def retrieve_numbers
@retrieve_numbers ||= split(/[\n#{delimiter}]/).map(&:to_i)
@frnz
frnz / frnz_osx.plugin.zsh
Created April 3, 2011 23:58
frnz_osx.plugin.zsh
# ------------------------------------------------------------------------------
# FILE: osx.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Sorin Ionescu ([email protected])
# VERSION: 1.0.1
# ------------------------------------------------------------------------------
function tab() {
local command="cd \\\"$PWD\\\" && clear"
@frnz
frnz / extras.zsh
Created April 3, 2011 23:57
extras.zsh
function cl() {
cd $1;
clear;
ls;
echo ""
}
function hack() {
function ~/1337/$1;
@frnz
frnz / frnz.zsh-theme
Created April 3, 2011 23:54
Frnz ZSH theme
local blue_op="%{$fg[blue]%}[%{$reset_color%}"
local blue_cp="%{$fg[blue]%}]%{$reset_color%}"
local path_p="${blue_op}%~${blue_cp}"
local user_host="${blue_op}%n@%m${blue_cp}"
local git_branch='$(git_prompt_info)%{$reset_color%}'
local rvm_branch='$(rvm_prompt_info)'
local ret_status="${blue_op}%?${blue_cp}"
local hist_no="${blue_op}%h${blue_cp}"
local smiley="%(?,%{$fg[green]%}:D$reset_color%},%{$fg[red]%}:@%{$reset_color%})"
PROMPT="╭─${path_p} ${user_host} ${rvm_branch} ${git_branch}
//Code sanitized to protect the foolish.
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Web.UI;
namespace Mobile.Web.Control
{
/// <summary>
@frnz
frnz / run_lola_run.el
Created February 1, 2011 05:36
Run, Lola! Run!
;; La idea es poder hacer algo como yasnippets (fácil de configurar, independiente de un modo) para comandos.
;; Entonces poder hacer algo como:
(lola-runs-on 'rails-minor-mode
("Run rake db:migrate"
:shortcut "C-c D"
:run "rake db:migrate"
;; project folder funciona como en textmate.el, busca el .git mas cercano. Tambien esta current-buffer-folder. De hecho project-folder es por default
:on project-folder)
@frnz
frnz / boludo.rb
Created January 7, 2011 16:21
Hash
{:password=>"39c8e9953fe8ea40ff1c59876e0e2f28", "username"=>"mitasdf", "password"=>"sdfsdfsdfsdf", "email"=>"[email protected]"}
Es que pensé que se usaba [:password] en params (como rails). Nada más usá "password" en lugar de :password:
def encript(hash)
# Devuelve el mismo hash, pero haciéndole digest al password
hash["password"] = Digest::MD5.hexdigest(hash["password"])
return hash
end
@frnz
frnz / diego.rb
Created January 7, 2011 13:25
Diego
# Primero te recomiendo hacer un método 'encript' así:
def encript(hash)
# Devuelve el mismo hash, pero haciéndole digest al password
hash[:password] = Digest::MD5.hexdigest(hash[:password])
return hash
end
# De esa manera podés hacer esto:
post '/signup' do
@frnz
frnz / diego_datamapper.rb
Created December 9, 2010 03:19
Diego's version:
class User
include DataMapper::Resource
has n, :projects
end
class Project
include DataMapper::Resource
belongs_to :user, :key => true
has n, :steps