Skip to content

Instantly share code, notes, and snippets.

View fedesilva's full-sized avatar
👁️‍🗨️

federico silva fedesilva

👁️‍🗨️
View GitHub Profile
==> manifest.json <==
{
"name": "GitHub Tweaks",
"version": "0.1",
"description": "Style tweaks for github pages",
"content_scripts": [
{
"matches": ["https://github.com/*", "https://gist.github.com/*"],
"css": ["tweaks.css"]
}
import org.scala_tools.time.Imports._
import org.scala_tools.time.Implicits._
case class Event(id: String, startDate: LocalDateTime, action: String)
case class Events(events: List[Event], timeout: Int) {
val timeoutDt: LocalDateTime = new LocalDateTime().minusMinutes(timeout)
lazy val oldEvents = events.filter { (e: Event) =>
@fedesilva
fedesilva / RecordFeatures.scala
Created November 25, 2010 11:53
Record Features
//
// A class does not need any reference to the `Mapper`.
// Here it is defined as a case class because it's convenient - no need for new and
// the compiler generates equals, hashCode, copy and extractor methods - but
// it can be a normal class.
//
case class Person( first:String, last:String, age:Int )
//
// A record does not need to be a class companion but it is convenient
@fedesilva
fedesilva / mutable.rb
Created November 26, 2010 16:12
Mutable arrays suck
#I would like to avoid having to explicitly clone the array. I want immutable collections.
ruby-1.8.7-p302 > segment = [ 192,168,20 ]
=> [192, 168, 20]
ruby-1.8.7-p302 > (180..185).map{ |i| segment.clone << i }
=> [[192, 168, 20, 180], [192, 168, 20, 181], [192, 168, 20, 182], [192, 168, 20, 183], [192, 168, 20, 184], [192, 168, 20, 185]]
ERROR 15:29:33,609 Uncaught exception in thread Thread[pool-1-thread-1,5,main]
java.lang.OutOfMemoryError: Java heap space
at org.apache.thrift.protocol.TBinaryProtocol.readStringBody(TBinaryProtocol.java:296)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:203)
at org.apache.cassandra.thrift.Cassandra$Processor.process(Cassandra.java:1154)
at org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:167)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Service exit with a return value of 100
//Usage:
//override def pomPostProcess(node: Node): Node = mcPom(moduleConfigurations)(super.pomPostProcess(node))
trait McPom { self: DefaultProject =>
import scala.xml._
def mcPom(mcs: Set[ModuleConfiguration])(node: Node): Node = {
//make sure we have a trailing slash so we deduplicate URLs properly
def cleanUrl(url: String) = url match {
case null => ""
@fedesilva
fedesilva / boost-stage.lo
Created December 17, 2010 18:27
boost stage tree
federico@debian-fede:~/Workshop/tmp/boost-stage$ tree
.
`-- lib
|-- libboost_date_time-gcc43-mt-1_44.so -> libboost_date_time-gcc43-mt-1_44.so.1.44.0
|-- libboost_date_time-gcc43-mt-1_44.so.1.44.0
|-- libboost_date_time-gcc43-mt-d-1_44.so -> libboost_date_time-gcc43-mt-d-1_44.so.1.44.0
|-- libboost_date_time-gcc43-mt-d-1_44.so.1.44.0
|-- libboost_date_time-gcc43-mt-d.so -> libboost_date_time-gcc43-mt-d-1_44.so.1.44.0
|-- libboost_date_time-gcc43-mt.so -> libboost_date_time-gcc43-mt-1_44.so.1.44.0
|-- libboost_filesystem-gcc43-mt-1_44.so -> libboost_filesystem-gcc43-mt-1_44.so.1.44.0
case class ElectricCar(b: Battery) { def batteryLevel = b.filledPercentage }
case class GasolineCar(g: GasTank) { def gasLevel = g.filledPercentage }
case class Battery(filledPercentage: Int) { def fill: Battery = Battery(100) }
case class GasTank(filledPercentage: Int) { def fill: GasTank = GasTank(100) }
trait Fills[C] {
def fill(car: C): C
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lenny32"
config.ssh.private_key_path="/home/federico/.ssh/id_rsa"