Skip to content

Instantly share code, notes, and snippets.

View gabrielfalcao's full-sized avatar

Gabriel Falcão gabrielfalcao

View GitHub Profile
# -*- coding: utf-8 -*-
# <bash_profile - for mac>
# Copyright (C) <2011> Gabriel Falcão <[email protected]>
#
# 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
# copies of the Software, and to permit persons to whom the
app.get('/robots.txt', function(req, res){
var rules = [
'User-agent: *',
'Disallow: /'
].join('\n');
res.send(rules, { 'Content-Type': 'text/plain' }, 200);
});
xhr.upload
[4/24/12 1:31:47 AM] Maxwell Dayvson: var fd = new FormData();
var file = this.input.files[0];
fd.append(this.input.name, file);
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt){});
xhr.upload.addEventListener("load", function(evt){});
xhr.upload.addEventListener("error", function(evt){});
xhr.upload.addEventListener("abort", function(evt){});
xhr.open("POST", "/url");
import ast
def get_safe_function(code):
expression = ast.parse(code).body[0]
if expression.value.__class__.__name__ == 'Lambda':
return eval(code)
else:
logger.warning("Got an unsafe code: %s", repr(code))
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
float ask_user_for_dollars(char *question){
char *string = malloc(13);
float dollars;
printf("%s\n", question);
scanf("%s", string);
#include <assert.h>
#include "converter.c"
void test_works_with_1_character(){
/* prepare the test */
char *expected = "one dollar";
char *given = convert_to_textual(1);
/* execute the test */
@gabrielfalcao
gabrielfalcao / tcp-socket-error-codes-errno.txt
Last active February 19, 2025 18:47
TCP socket error codes
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
compile qt
./configure -prefix /usr/local/Cellar/qt/4.8.3 -system-libpng -system-zlib -confirm-license -opensource -cocoa -fast -L/opt/X11/lib -I/opt/X11/include -no-qt3support -nomake demos -nomake examples -release
@gabrielfalcao
gabrielfalcao / gist:4270993
Created December 12, 2012 19:53
utility to manage services
SERVICES="mysql redis elasticsearch mongo"
SERVICE_LOAD_mysql="mysqld"
SERVICE_LOAD_mongo="mongod"
SERVICE_LOAD_redis="redis-server /usr/local/etc/redis.conf"
SERVICE_LOAD_elasticsearch="elasticsearch -f -D es.config=/usr/local/opt/elasticsearch/config/elasticsearch.yml"
daemonize-service (){
name=$1
shift
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);