Skip to content

Instantly share code, notes, and snippets.

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

Rafael Fidelis fidelisrafael

🏠
Working from home
  • https://web.archive.org/web/20221024062310/http://www.fidelis.work/
  • Brasil
  • 10:49 (UTC -03:00)
View GitHub Profile

Basic

import code; code.interact(local=locals())

Advanced

IPython with embed()

@everaldo
everaldo / municipios.yml
Created April 22, 2014 13:48
Lista de UFs e Municípios, segundo IBGE 2013 (5570 municípios)
---
- :cod_uf: '52'
:uf: Goiás
:city_id: '00050'
:city: Abadia de Goiás
:sigla_uf: GO
:city_code: '5200050'
- :cod_uf: '31'
:uf: Minas Gerais
:city_id: '00104'
@fidelisrafael
fidelisrafael / app.js
Last active August 26, 2021 02:15
Easy way to export data to XLS format using Node.js
// clone this gist to a empty folder, the run:
// npm init (and follow steps)
// npm install express --save
// npm install swig --save
// node app.js and open http://localhost:3000
function App() {
var express = require('express');
@netojoaobatista
netojoaobatista / 1st-case.php
Last active December 29, 2015 17:39
Comparação entre strings com aspas e apóstrofos no PHP
<?php
$a = 'Neto';
echo $a;
@schickling
schickling / Rakefile
Last active January 31, 2024 23:00
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)

Today, in Ruby, if I want to make a network request, I block

response = Net::HTTP.get("/post/1")

If I want to do multiple requests in parallel, I can use a thread per request

responses = ["/post/1", "/post/2"].map do |url|
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@wycks
wycks / fuckstrap.css
Last active December 17, 2015 06:29
FuckStrap.css - A framework so terse it shits diamonds.
/*Pixel straps start here*/
/*Scroll hard for % straps*/
.0{ width: 0px;}
.1{ width: 1px;}
.2{ width: 2px;}
.3{ width: 3px;}
.4{ width: 4px;}
.5{ width: 5px;}
.6{ width: 6px;}
@cslarsen
cslarsen / human-numbers.cpp
Created February 20, 2012 18:44
Convert big number to human readable format
/*
* A simple way to format numbers as human readable strings.
* E.g., 123456789 ==> 123 million
*
* Written by Christian Stigen Larsen
* http://csl.sublevel3.org
*
* Placed in the public domain by the author, 2012
*/