Skip to content

Instantly share code, notes, and snippets.

View annacruz's full-sized avatar
🏠
Working from home

Anna Cruz annacruz

🏠
Working from home
View GitHub Profile
@annacruz
annacruz / gist:3489202
Created August 27, 2012 14:52
UUID as primary key Rails
When you're using UUID as primary key field your tests will be broken, so to fix it take there steps:
- Remove your db/schema.rb file
- Add the following line in your application.rb file
config.active_record.schema_format = :sql
- Then after you run your migrations and before you run rake db:test:prepare run:
rake db:structure:dump
@annacruz
annacruz / gist:3494100
Created August 28, 2012 01:29
Truth Table
True and True is True
True and False is False
False and True is False
False and False is False
True or True is True
True or False is True
False or True is True
False or False is False
@annacruz
annacruz / gist:3494103
Created August 28, 2012 01:30
Adding gmail notifications to Mountain Lion
window.webkitNotifications.requestPermission(function(){alert(window.webkitNotifications.checkPermission())});
@annacruz
annacruz / gist:3738510
Created September 17, 2012 17:04
sublime text ppa over proxy
add the http_proxy and https_proxy to .bashrc
export http_proxy='user:pass@proxy'
export https_proxy='user:pass@proxy'
sudo visudo
then add the following lines
Defaults env_keep="http_proxy"
Defaults env_keep="https_proxy"
@annacruz
annacruz / aliases.rb
Created October 9, 2012 18:23
RAILS HTTP HEAD ALIASES
HTTP_STATUS_CODES = {
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
import javax.swing.JOptionPane;
public class MaiorMenor {
public static void main(String[] args) {
String argumento;
int maior = 0;
int menor = Integer.MAX_VALUE;
it "instantiates record with params" do
# require 'pry'; binding.pry
url = mock_model(Url)
post :create, :original_url => "http://example.org"
Url.should_receive(:new).with({"original_url" => "http://example.org"}).and_return(url)
end
insmod datapath/linux/openvswitch_mod.ko
rmmod bridge ou modprobe -r bridge
mkdir -p /usr/local/etc/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,manager_options \
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
int N;
double dist[20][20], memo[1 << 16];
double matching(int bitmask) {
@annacruz
annacruz / anagram.rb
Last active December 16, 2015 17:39
first_string = "amor"
second_string = "maro"
if (first_string.chars.sort == second_string.chars.sort)
puts "ANAGRAM"
else
puts "TRY ANOTHER WORD"
end