Skip to content

Instantly share code, notes, and snippets.

View d1rtym0nk3y's full-sized avatar

Chris Blackwell d1rtym0nk3y

View GitHub Profile
if (typeof console != "object") { console = {log: function(){} } };
@d1rtym0nk3y
d1rtym0nk3y / Ant.sublime-build
Created February 7, 2012 14:16
SublimeText2 Ant build config
// save this as /Users/%user%/AppData/Roaming/Sublime Text 2/Packages/User/Ant.sublime-build
// on windows, or somewhere else on mac/linux
// make sure its "ant.bat" or it will moan about file not found
{
"cmd": ["ant.bat", "-f", "build.xml", "-DBUILD_HOST=local", "main"],
"working_dir": "$project_path"
}
<!---
example of using DirectoryTestSuite to run mxunit tests
assumes your tests are located at /tests/unit, or there is a mapping to that location
and that tests are organised into modules under this directory
--->
<cfif not structkeyexists(url, "module")>
<cfdirectory action="list" directory="#expandPath('.')#" name="dir" >
<cfoutput>
@d1rtym0nk3y
d1rtym0nk3y / coldspring.xml
Created January 22, 2013 12:12
coldspring 2 util:map bug on Railo
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.coldspringframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.coldspringframework.org/schema/util"
xsi:schemaLocation="http://www.coldspringframework.org/schema/beans http://coldspringframework.org/schema/coldspring-beans-2.0.xsd
http://www.coldspringframework.org/schema/util http://coldspringframework.org/schema/coldspring-util-2.0.xsd">
<util:map id="mapBean">
<entry key="keya" value="key a value"/>
<entry key="keyb" value="key b value"/>
private static long getCode(byte[] secret, long timeIndex)
throws NoSuchAlgorithmException, InvalidKeyException {
SecretKeySpec signKey = new SecretKeySpec(secret, "HmacSHA1");
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.putLong(timeIndex);
byte[] timeBytes = buffer.array();
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(signKey);
byte[] hash = mac.doFinal(timeBytes);
int offset = hash[19] & 0xf;
component {
env = createObject("java", "java.lang.System").getenv();
this.name = "heroku-demo-app";
this.sessionManagement = true;
this.datasources.default = {
class: env.get("DB_DRIVER")
,connectionString: env.get("DB_URL")
@d1rtym0nk3y
d1rtym0nk3y / Application.cfc
Created April 1, 2013 18:08
per application datasource parsed from environemnt variable with Railo 4.1
component {
sysenv = createObject("java", "java.lang.System").getenv();
dbUri = createobject("java", "java.net.URI").init(env("DATABASE_URL"));
this.datasources.default = {
class:'org.gjt.mm.mysql.Driver'
,connectionString:'jdbc:mysql://#dbUri.getHost()##dbUri.getPath()#?#dburi.getQuery()#'
,username: listfirst(dbUri.getUserInfo(), ":")
,password: listlast(dbUri.getUserInfo(), ":")
<cfsetting requesttimeout="999999" enablecfoutputonly="true" />
<cfscript>
progress("Importing data", 0);
recordcount = 100;
for(i=1; i<=recordcount; i++) {
// do something
sleep(250);
progress("Importing data", i, recordcount)
}
@d1rtym0nk3y
d1rtym0nk3y / gist:6192227
Last active December 20, 2015 20:39
copy your public key to the authorized_keys file on a remote machine
cat ~/.ssh/id_rsa.pub | ssh root@server "(cat > tmp.pubkey ; mkdir -p .ssh ; touch .ssh/authorized_keys ; sed -i.bak -e '/$(awk '{print $NF}' ~/.ssh/id_rsa.pub)/d' .ssh/authorized_keys; cat tmp.pubkey >> .ssh/authorized_keys; rm tmp.pubkey)"
//Application.cfc
component extends="fw1" {
// omiting all the usualy fw1 stuff..
function setupRequest() {
// this is just a wrapper around a singleton instance of the java class com.newrelic.api.agent.NewRelic
var nr = getBeanFactory().getBean("NewRelic");
// setup newrelic to track the this request
nr.setTransactionName( nullValue(), "/#getFullyQualifiedAction()#");
// track whatever custom values you need
nr.addCustomParameter( "session_id", session.sessionid );