Skip to content

Instantly share code, notes, and snippets.

View markmarch's full-sized avatar

Xiaoming Jia markmarch

View GitHub Profile
int add_count(unsigned long delta)
{
int c;
int cm;
int old;
int new;
do {
split_counterandmax(&counterandmax, &old, &c, &cm);
if (delta > MAX_COUNTERMAX || c + delta > cm)
@markmarch
markmarch / gist:1233408
Created September 21, 2011 21:45
Rats! example
/**
* Syntax Analysis production
* void means do not create AST
* / means ordered alternative
*/
module Sample;
header { import java.util.*;}
body { public static final Set<String>
@markmarch
markmarch / gist:1299867
Created October 19, 2011 22:25
Syntax directed translation
// Example of computing attributes in Rats!
AssignStmt assignStmt = l : expr COLONEQ r : expr { yyValue = new AssignStmt(l, r) }
// class that represents an assignment statement node.
class AssignStmt extends Stmt {
Expression _lhs, _rhs; // children
public AssignStmt(Expression l, Expression r) {
_lhs = l;
_rhs = l;
}
@markmarch
markmarch / t.scala
Created October 29, 2011 17:59
testing
object Hello extends App{
println "hello"
}
@markmarch
markmarch / gist-it
Created November 29, 2011 05:42
gist-it test
Hello Gist
def drop[T](list: List[T], n: Int): List[T] = {
@tailrec
def loop(l: List[T], n: Int): List[T] = l match {
case Nil => l
case _ if n == 0 => l
case x :: xs => loop(xs, n - 1)
}
loop(list, n)
}
@markmarch
markmarch / Macros.scala
Created January 6, 2013 09:39
simple macro use case
import scala.language.experimental.macros
import scala.reflect.macros.Context
/** Trying out macros in Scala 2.10 */
object Macros {
def compiledTime(): String = macro compiledTime_impl
def compiledTime_impl(c: Context)(): c.Expr[String] = {
import c.universe._
val date = c.Expr[String](Literal(Constant(new java.util.Date().toString)))

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
$ cat ~/.sbtconfig
SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:PermSize=128M -XX:MaxPermSize=256M"

Sublime Text 2 – Useful Shortcuts (OS X)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Cmd+C copy current line (if no selection)
Cmd+X cut current line (if no selection)
Cmd+⇧+K delete line
Cmd+↩ insert line after