Skip to content

Instantly share code, notes, and snippets.

View tc's full-sized avatar
💭
🚢

Tommy Chheng tc

💭
🚢
View GitHub Profile
@tc
tc / activemq.xml
Created March 22, 2011 20:18
Not working ActiveMQ conf file
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@tc
tc / ActiveMQ simpleAuthenticationPlugin
Created March 24, 2011 17:05
activemq auth config
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser
username="user"
password="test"
groups="admins,publishers,consumers"
/>
</users>
</simpleAuthenticationPlugin>
@tc
tc / Different java concurrency usage in scala
Created April 8, 2011 20:31
Different java concurrency usage in scala
class Fetch(val url:String) extends Runnable{
override def run{
println(scala.io.Source.fromURL(url).mkString)
}
}
val urls = List("http://news.com", "http://cnn.com", "http://stackoverflow.com", "http://abc.com")
val threads = urls.map{ url =>
val thread = new Thread(new Fetch(url))
@tc
tc / gist:987882
Created May 23, 2011 23:46
helper functions for managing processes
# helper functions for managing processes
def run_system_command(cmd)
puts cmd
status = system(cmd)
$?.exitstatus
end
def kill_matching_process_cmd(process_name)
cmd = "echo `ps -ef | grep -v grep | grep \"#{process_name.gsub("-", "\\-")}\" | awk '{print $2}'` | xargs kill"
@tc
tc / lift-json 2.4M1 incorrectly parsing option classes?
Created July 12, 2011 05:21
lift-json 2.4M1 incorrectly parsing option classes?
import org.junit.{Test, Assert}
import org.junit.Assert._
import net.liftweb.json._
import net.liftweb.json.Serialization.write
case class Library(name:String, docs:List[Option[String]])
class AppTest{
@Test
def testMain{
@tc
tc / gist:1144240
Created August 13, 2011 20:51
profile
# Colors from http://wiki.archlinux.org/index.php/Color_Bash_Prompt
# misc
NO_COLOR='\e[0m' #disable any colors
# regular colors
BLACK='\e[0;30m'
RED='\e[0;31m'
GREEN='\e[0;32m'
YELLOW='\e[0;33m'
BLUE='\e[0;34m'
MAGENTA='\e[0;35m'
@tc
tc / gist:1217766
Created September 14, 2011 20:57
resize and crop using imagej -java version
package imagej;
import ij.*;
import ij.io.*;
import ij.process.*;
import java.io.*;
import javax.imageio.*;
import javax.imageio.stream.*;
import java.awt.image.BufferedImage;
@tc
tc / gist:1271074
Created October 7, 2011 18:52
Cloudfront invalidate script
require 'openssl'
require 'uri'
require 'net/http'
require 'net/https'
require 'base64'
require 'optparse'
class CloudfrontDistribution
@tc
tc / gist:1411478
Created November 30, 2011 22:36
Anarchism wikitext
{{Redirect|Anarchist|the fictional character|Anarchist (comics)}}{{Redirect|Anarchists}}{{about|the political philosophy|the medical condition|Anorchism}}{{Anarchism sidebar}}{{Libertarianism sidebar}}'''Anarchism''' is generally defined as the [[political philosophy]] which holds the [[state (polity)|state]] to be undesirable, unnecessary, and harmful,<ref name="definition">{{Cite journal|last=Malatesta|first=Errico|title=Towards Anarchism|journal=MAN!|publisher=International Group of San Francisco|location=Los Angeles|oclc=3930443|url=http://www.marxists.org/archive/malatesta/1930s/xx/toanarchy.htm|authorlink=Errico Malatesta}}{{Cite journal|url=http://www.theglobeandmail.com/servlet/story/RTGAM.20070514.wxlanarchist14/BNStory/lifeWork/home/|title=Working for The Man |journal=[[The Globe and Mail]] |accessdate=2008-04-14 |last=Agrell |first=Siri |date=2007-05-14}}{{cite web|url=http://www.britannica.com/eb/article-9117285|title=Anarchism|year=2006|work=Encyclopædia Britannica|publisher=Encyclopædia Britanni
@tc
tc / gist:1984052
Created March 6, 2012 06:16
solr config, debugging exact match rankings
solrconfig.xml:
<requestHandler class="solr.SearchHandler" name="ac" default="true" >
<lst name="defaults">
<str name="defType">edismax</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
<str name="qf">title^50.0 textng^40.0</str>
<str name="pf">textnge^50.0</str>
<str name="debugQuery">false</str>
<str name="timeAllowed">5000</str>