Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
#!/bin/sh
kill -9 $(echo `ps aux | grep tomcat | grep -v grep |awk '{print $2}'`)
import akka.stm._
import scala.collection.immutable.ListMap
case class LRUCache[A, B](private val MAX_ENTRIES: Int)
{
protected val cache = Ref(ListMap.empty[A, B])
def getOrElse(key: A)(fn: => B): B = {
get(key).getOrElse {
val result = fn
class LRUCache
constructor: (size_limit) ->
@limit = size_limit or Infinity
@data = {}
@size = 0
@order = []
set: (key, val) ->
@data[key] = val
@size++
@order.push key
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends ([A-Za-z][A-Za-z0-9_.]*)+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
--regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
@nmccready
nmccready / gulpfile.coffee
Created June 30, 2014 14:12
Make sure clean happens first and is finished, then execute other tasks with max parallelism . This is important as clean can be in the middle of deleting otherwise and then one,two or three could be creating files or dirs. If this happens or collides then you will get rmdir or rmfile errors inconsistently.
gulp.task "clean", ->
gulp.src('dist', read: false)
.pipe clean()
gulp.task "one", ->
gulp.task "two", ->
gulp.task "three", ->
gulp.task "default", ["clean"], ->
gulp.start ["one","two","three"]
@nmccready
nmccready / gulpfile.coffee
Created June 30, 2014 14:12
execute in order
gulp.task "one" ->
gulp.task "two", ["one"], ->
gulp.task "three", ["two"], ->
gulp.task "default" ["one","two","three"] # now they should execute in order, this is not ideal for cleaning at all as clean may need ot be a dependency everywhere
@nmccready
nmccready / gulpfile.coffee
Created June 30, 2014 14:13
gulp async bs, nothing waits here, this just means default runs one, two, three and they are parallel
gulp.task "one", ->
gulp.task "two", ->
gulp.task "three", ->
gulp.task "default" ["one","two","three"]
@nmccready
nmccready / dynamic-height.css
Created July 30, 2014 14:04
Example for html on angular google maps for having dynamic height.
/*
let me google that for you (many ways to skin this cat)
http://stackoverflow.com/questions/10209704/set-google-maps-container-div-width-and-height-100 (implemented here)
http://stackoverflow.com/questions/2821596/100-height-with-fixed-footer-and-embedded-google-map
*/
body, html {
height: 100%;
width: 100%;
}
@nmccready
nmccready / de-crapify-google-plus.css
Created September 8, 2014 15:40
CSS to only show google hangouts on plus.google.com homepage
/* your source here */
.Bdc.FQb{
display:none;
}
.vyd{
display:none;
}
.Of.ooe.Xt.N3.gb_gbsf.gb_gbshc{
@nmccready
nmccready / gist:b11c8cfb6eedde5ac82e
Created September 10, 2014 00:41
example of using lsof and awk to get just a pid of a running process on a specific port.
#!/bin/sh
port=${1:-8000}
lsof -i:$port | grep -v PID | awk '{print $2}'