Skip to content

Instantly share code, notes, and snippets.

@ikenna
ikenna / gist:5706366
Created June 4, 2013 14:30
Informix "select 1 from dual "
select 1 from systables where tabid = 1
@ikenna
ikenna / stopwatch.rb
Last active April 21, 2021 15:01
Simple Ruby stopwatch
class Stopwatch
def initialize()
@start = Time.now
end
def elapsed_time
now = Time.now
elapsed = now - @start
puts 'Started: ' + @start.to_s
@ikenna
ikenna / MyFunctionalTest.scala
Created November 6, 2013 12:37
Functional test in Scala Play Framework 2.2 using ScalaTest
package net.ikenna
import play.api.test.Helpers.running
import play.api.test.{FakeApplication, TestServer}
import org.scalatest.FunSuite
import play.api.libs.ws.{Response, WS}
class MyFunctionalTest extends FunSuite {
import scala.concurrent.{Future, Await}
@ikenna
ikenna / .sbtrc
Created February 5, 2014 10:57
.sbtrc
alias g=gen-idea
alias r=reload
alias u=update
alias t=test
alias st = ;container:stop; container:start;
@ikenna
ikenna / specs.scala
Last active August 29, 2015 13:56 — forked from teamon/specs.scala
// === Basics
a must beMatching(bar)
a must be matching(bar)
a must not be matching(bar) // negation
// === Any object
a must_== b
a must_!= b
@ikenna
ikenna / gist:10466022
Created April 11, 2014 12:49
Fixing intellij Scala formatting for functions curly braces
Luckily this is easy to fix. From IntelliJ's settings, find the following:
settings -> code style -> Scala -> Wrapping and braces
in "Anonymous method definition"
uncheck "parameters on new line"
@ikenna
ikenna / Write to a file in Scala
Created January 14, 2015 13:19
Write to a file in Scala
def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) {
val p = new java.io.PrintWriter(f)
try { op(p) } finally { p.close() }
}
//Usage
printToFile(new File("fileName.txt"))(p => p.write("someString"))
@ikenna
ikenna / print system and environment properties in sbt console
Last active February 29, 2024 15:00
SBT print system properties and env proprties
sbt> eval new scala.sys.SystemProperties().foreach(x => println(x))
sbt> eval scala.sys.env.foreach(x => println(x))
@ikenna
ikenna / RandomAscii.scala
Last active September 7, 2015 11:38
random ascii string generator in Scala
// random ascii string generator in Scala
def randomString(length: Int) = List.fill(length)(Random.nextPrintableChar).foldRight("")((nextChar, ref) => ref + nextChar)
print(randomString(10))
@ikenna
ikenna / clean_code.md
Created July 22, 2017 09:49 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules