This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake () { | |
if [ -e bin/rake ] | |
then | |
bin/rake $@ | |
elif [ -e Gemfile ] | |
then | |
bundle exec rake $@ | |
else | |
command rake $@ | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This validator makes it easy to force a date to be after or before another. | |
# | |
# validate :end_date, time_range: { after: :start_date } | |
# validate :created_at, time_range: { before: :deleted_at } | |
# | |
# You can pass messages for each type of comparisson. | |
# | |
# validate :end_date, time_range: { after: :start_date, after_message: "Foo" } | |
# validate :end_date, time_range: { after: :start_date, message: "Default message" } | |
class TimeRangeValidator < ActiveModel::EachValidator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Build the image to be used for this job. | |
IMAGE=$(docker build . | tail -1 | awk '{ print $NF }') | |
echo "Image $IMAGE" | |
# Build the directory to be mounted into Docker. | |
MNT="$WORKSPACE" | |
echo "Mounting on $MNT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
#define MAXN 100005 | |
#define D(x) cout << #x " is " << x << endl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <algorithm> | |
#include <cstdlib> | |
#include <vector> | |
#include <queue> | |
#include <iterator> | |
#include <map> | |
#include <set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class people::nhocki::emacs { | |
notice("Setting up ${::boxen_user}'s emacs repo") | |
package { 'cask': | |
ensure => present | |
} | |
$home = "/Users/${::boxen_user}" | |
$src = "${home}/src" | |
$emacs = "${src}/emacsdotd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int n; | |
inline int index(int i){ if (i > 0) return i; else return n - i; } | |
inline int no(int i){ return -1*i; } //negation of a node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/puntos.rb | |
class Puntos < AR::Base | |
PUNTOS_ALL_KEY = "all_puntos".freeze | |
after_save :expire_cache | |
after_destroy :expire_cache | |
# Guarda un arreglo de hashes con el JSON pa mandar. | |
def self.all_cached | |
Rails.cache.fetch(PUNTOS_ALL_KEY) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Convierte un numero N en base B a decimal | |
public int toDecimal(int n, int b) | |
{ | |
int result=0; | |
int multiplier=1; | |
while(n>0) | |
{ | |
result+=n%10*multiplier; | |
multiplier*=b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set<int>f,s,tmp; | |
set_intersection(all(f),all(s), inserter(tmp, tmp.begin())); |