Skip to content

Instantly share code, notes, and snippets.

View dallarosa's full-sized avatar

Francisco Dalla Rosa Soares dallarosa

View GitHub Profile
import sys
import math
def solution():
l_range = xrange
l_int = int
l_str = str
for index,line in enumerate(open(sys.argv[1])):
if index != 0:
if len(line) == 3:
class News < ActiveRecord::Base
include Translation::Google
attr_accessible :date, :description, :link, :title, :language
has_many :translations
def after_save
Translation.create({news_id: self.id, description:translate(self.description, self.language, "ja"), title: translate(self.title, self.language, "ja"), language: "ja" })
end
@dallarosa
dallarosa / gist:3866890
Last active October 11, 2015 13:37
Fibonnaci closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
n := []int{0,1}
return func() int {
value := n[0]
@dallarosa
dallarosa / gist:4138735
Created November 24, 2012 07:07
create new project directory
mkdir newproject
cd newproject
@dallarosa
dallarosa / gist:4138780
Created November 24, 2012 07:24
initializing a new repository
git init
@dallarosa
dallarosa / gist:4138821
Created November 24, 2012 07:53
first commit
echo "私の初めてのレポジトリを作成してみた!" > README.md
git add README.md
git commit -m "私の初めてのコミット"
@dallarosa
dallarosa / balancedsmiles.go
Created February 2, 2013 06:44
My solutions for the 2013 hacker cup qualification round in Go. My original solution for balanced smiles is broken but i'm gonna fix it
package main
import (
"fmt"
"os"
"io/ioutil"
"strings"
"strconv"
"./stack"
)
@dallarosa
dallarosa / emptyinterface.go
Created July 5, 2013 06:25
Example of use of empty interface
package main
import (
"fmt"
)
type myStruct struct {
RandomString string
RandomNumber int
}
for i in $(grep -e "\./g[(cc|libc)].*txz$" ../FILELIST.TXT | awk '{print $9}'); do wget http://connie.slackware.com/~alien/multilib/current/$i; done
for i in $(grep -e "slackware64-compat32/.*txz$" ../FILELIST.TXT | awk '{print $9}'); do wget http://connie.slackware.com/~alien/multilib/current/$i; done
@dallarosa
dallarosa / asound.conf
Last active December 27, 2015 10:39
adding bluetooth audio support to linux
pcm.btheadset {
type plug
slave {
pcm {
type bluetooth
device DEVICE_MAC_ADDRESS
profile "auto"
}
}
hint {