Skip to content

Instantly share code, notes, and snippets.

// Infinite runner!
import "sounds"
clear
display(5).mode = displayMode.tile
td = display(5)
td.extent = [150, 10]
td.tileSet = file.loadImage("/sys/pics/SimplePlatformTiles.png")
td.tileSetTileSize = [64,64]
@achadwick
achadwick / pygi-grep
Last active February 27, 2017 19:19
Python-GI name search tool
#!/usr/bin/env python
# Search for names known to Python GObject-Introspection.
# All rights waived: https://creativecommons.org/publicdomain/zero/1.0/
from __future__ import print_function
import importlib
import os.path
import sys
import re
from optparse import OptionParser
@ElectricCoffee
ElectricCoffee / SafeConvert.scala
Created September 6, 2014 14:33
Got a little miffed by the fact that str.toInt threw an exception if a non-convertible string was encountered (a-la "hello".toInt), so I figured it would make more sense if it returned an option instead, using this library you can do this: "hello".opt.toInt which would return None, saving you a tedious try/catch
package com.wausoft.extensions
object SafeString {
class StrOps(input: String) {
private def toOption[A](in: => A) = try {
Some(in)
} catch {
case _: Throwable => None
}
@sebnozzi
sebnozzi / PlayBrowserSpec.scala
Last active November 8, 2016 02:15
How to integrate ScalaTest (FlatSpec) with Play
import org.scalatest.BeforeAndAfterAll
import org.openqa.selenium.WebDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.scalatest.FlatSpec
import play.api.test.TestServer
import org.scalatest.Matchers
import play.api.test.Helpers
import org.scalatest.selenium.WebBrowser
import play.api.test.FakeApplication
@chirlo
chirlo / Game.scala
Last active December 23, 2015 01:59
TicTacToe with Either
sealed trait Result
case object X extends Result
case object O extends Result
case object Tie extends Result
object Game {
type Player = (Result, Set[Int])
private val emptySet: Set[Int] = Set()
private val availableSquares = (1 to 9).toSet
anonymous
anonymous / gist:4639734
Created January 26, 2013 02:31
RoboVM IOSDemo ported to Scala + some additional crap.
import org.robovm.cocoatouch.coregraphics._
import org.robovm.cocoatouch.foundation._
import org.robovm.cocoatouch.uikit._
object Utils {
import scala.language.implicitConversions
implicit class RichUIControl(control: UIControl) {
package net.fwbrasil.sReflection
object CascadeImplicits {
implicit def toYourself[T](value: T): Yourself[T] = new Yourself(value)
implicit def toCascade[T](value: T): Cascade[T] = new Cascade(value)
class Yourself[T](value: T) {
def yourself = value
}
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@ostronom
ostronom / CountryController.scala
Created February 20, 2012 17:00
Play 2.0 & squeryl simple integration
package controllers
import org.squeryl.PrimitiveTypeMode._
import org.squeryl.{Session}
import play.api._
import play.api.mvc._
import models._