Skip to content

Instantly share code, notes, and snippets.

@damianknopp
damianknopp / 2WayTaggle
Created January 23, 2013 17:03
2 way form taggle
HTML
---------------------
<div class="f1 hide">
<form>
<input type="radio" name="c" value="f1" checked>f1
<input type="radio" name="c" value="f2">f2<br />
</form>
<p>Welcome to my form1</p>
</div>
<div class="f2 hide">
@damianknopp
damianknopp / truncateUntilFirst
Created January 24, 2013 20:16
remove all chars up to and including the given sequence
String.prototype.isEmpty = function(){
return (!this || 0 === this.length);
}
String.prototype.truncateUntilFirst = function(str){
if(!str || !str.isEmpty()){
return this;
}
if(this.isEmpty()){
@damianknopp
damianknopp / copy-stream.sh
Created February 14, 2013 20:07
copy stream
dd if=/var/local/file.tar.gz | ssh ${USER}@${DEST} "ssh ${USER}@{DEST2} 'cat > file2.tar.gz'
# On DEST2
mv ~/file2.tar.gz /opt
gunzip -dc file2.tar.gz | tar -xvf -
if(typeof dmk === "undefined"){
dmk = {};
if(typeof dmk.oo === "undefined"){
dmk.NameSpace = {};
}
}
/**
* static method,
* assumes the name spaces {Arra} is in order, ie ["dmk", "dmk.namespace1"]
if(typeof dmk === "undefined"){
dmk = {};
if(typeof dmk.oo === "undefined"){
dmk.oo = {};
}
}
/** function constructor **/
dmk.oo.Class1 = function(config){
this.member1 = config.member1;
Component = Class.extend({
// constructor
init: function(){
this.message = "I'm a class member!";
// on click
$("#myBtn").on("click", _.bind(this.callBack, this));
},
// call back
@damianknopp
damianknopp / BootStrap.groovy
Created March 6, 2013 19:05
load resources from classpath on startup
import org.codehaus.groovy.grails.commons.ApplicationHolder
class BootStrap {
def init = { servletContext ->
def filePath = "resources/loadme.txt"
def text = ApplicationHolder.application.parentContext.getResource("classpath:$filePath").inputStream.text
println "found text = $text"
@damianknopp
damianknopp / Cakefile
Created March 25, 2013 03:17
simple coffeescript and lessc build. Probably should look into watch compile, https://npmjs.org/package/watch-compile
fs = require 'fs'
{exec} = require 'child_process'
src = "src/main/webapp"
dest = "bin"
lessc = "lessc"
# clean
task 'clean', "Clean project build dir #{dest}", ->
console.log "Cleaning build directory #{dest}..."
@damianknopp
damianknopp / logGrep1.sh
Created March 14, 2014 15:22
cat, grep, truncate, more
cat log.txt | grep EXPRESSION | sed 's/.*EXPRESSION://g' - | more
@damianknopp
damianknopp / SolrIndexer.java
Created March 18, 2014 23:02
index into solr, and quickly please
package dmk.solr;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;