This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When you do this: | |
class Person < ActiveRecord::Base | |
end | |
people = Person.where(name: "Foo") | |
people.each do | |
# Do something with each row | |
end | |
# You're instantiating a relation, which includes this module: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import concurrent._ | |
import concurrent.duration._ | |
import ExecutionContext.Implicits.global | |
object ScalaFutures extends App { | |
val fusers = findFromDB | |
val finternet = findFromInternet | |
val result = for( | |
list_users <- fusers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'config-1.2.0.jar' | |
require 'java' | |
require 'scala-library.jar' | |
require 'akka-actor_2.10-2.3.2.jar' | |
java_import 'akka.actor.UntypedActor' | |
java_import 'akka.actor.Actor' | |
java_import 'akka.actor.ActorRef' | |
java_import 'akka.actor.ActorSystem' | |
java_import 'akka.actor.UntypedActorFactory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'tu_prolog' | |
class Lib < TuProlog::RubyLibrary | |
def getTheory | |
<<-THEORY | |
create_board :- | |
member(Col, ['A', 'B', 'C']), | |
member(Row, ['1', '2', '3']), | |
asserta(board(Col, Row, ' ')). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Fixes a MySQL dump made with the right format so it can be directly | |
imported to a new PostgreSQL database. | |
Dump using: | |
mysqldump --compatible=postgresql --default-character-set=utf8 -r databasename.mysql -u root databasename | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Javascript#index</h1> | |
<div data-update='bottom'> | |
Nada | |
</div> | |
<br /> | |
<div data-update='true'> | |
Zero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script src="prototype.js"></script> | |
<style> | |
.bold { | |
font-weight: bold; | |
} | |
</style> | |
<div id='pessoas'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'pdf/reader' | |
require "re_parser" | |
require "yaml" | |
class PageTextReceiver | |
attr_accessor :disciplinas | |
def initialize | |
@disciplinas = ReParser.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = | |
putStrLn (show $ trocoPara 50) | |
trocoPara quantia = | |
let todasCombinacoes = todasPossibilidades (quantia `div` (last todasMoedas)) [] | |
in filter (\c -> (sum c) == quantia ) todasCombinacoes | |
todasPossibilidades num ps = | |
if num == 0 then ps | |
else concat [ (possibilidades num), (todasPossibilidades (num - 1) ps) ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
OlderNewer