Skip to content

Instantly share code, notes, and snippets.

@jaimefjorge
jaimefjorge / foo
Created December 3, 2013 17:29
Stuff
bar
@jaimefjorge
jaimefjorge / NumerousCloneGroup.c
Created December 1, 2011 22:56
Kamino: Most numerous clone group (most number of code fragments)
// Most numerous clone group
// code fragment:
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
// files:
//neo/tools/af/DialogAFConstraintSlider.cpp 288:290
//neo/tools/af/DialogAFConstraintSlider.cpp 310:312
@jaimefjorge
jaimefjorge / doom3Largest.c
Created December 1, 2011 20:36
Kamino Largest Clone detected in Doom 3
// This code fragment exists in two separate files:
// 1- neo/game/script/Script_Interpreter.cpp
// 2- neo/d3xp/script/Script_Interpreter.cpp
//
while( !doneProcessing && !threadDying ) {
instructionPointer++;
if ( !--runaway ) {
Error( "runaway loop error" );
}
@jaimefjorge
jaimefjorge / ListToTuple.scala
Created November 2, 2011 13:40
List to TupleN
object ListToTupleImplicit {
class ListToTuple[A](xs:List[A]){
def toTuple2 = (xs(0),xs(1))
def toTuple3 = (xs(0),xs(1),xs(2))
def toTuple4 = (xs(0),xs(1),xs(2),xs(3))
}
implicit def listToTuple[A](xs:List[A]):ListToTuple[A] = new ListToTuple(xs)
}
@jaimefjorge
jaimefjorge / arrows.scala
Created September 15, 2011 17:57
My Scalaz error
import scalaz._
import Scalaz._
scala> val a = (_:List[Int]).partition(_ > 5)
a: List[Int] => (List[Int], List[Int]) = <function1>
scala> val b = (_:List[Int]).partition(_ > 10)
b: List[Int] => (List[Int], List[Int]) = <function1>
scala> val c = (_:List[Int]).map(_ + 1)
@jaimefjorge
jaimefjorge / style.scala
Created July 20, 2011 07:46
Scala Coding Method Chaining style
/**
* This is from community accepted conventions and feel free to judge upon them.
*
* Upon Method Invocation chaining, one can prefer the 'fooIndent' method over 'fooNotIndent'
* (as well as barIndent over barNotIndent),
* Not only it improves readibility upon reading (by gradually grasping the functionality) but also it does not consume
* the whole screen (thus not making you scroll).
*
* The use of '.' upon invocation is debatable.
* Some argue that the leading '.' should be removed [2]
@jaimefjorge
jaimefjorge / scalaCliffHanger.scala
Created June 10, 2011 05:06
cliff hanger in Scala done in 15 minutes
object cliffHanger extends App{
val man = List(" 0\n","-","-","-\n"," |\n"," /","\\\n")
def drawState(tries:Int,word:String,letters:List[Char]) = {
println("\n\n\n")
println(man.dropRight(tries).mkString)
word.toList.foreach(c => if (letters.exists(c == _)) print(c) else print("_"))
println()
}