Skip to content

Instantly share code, notes, and snippets.

@lifuzu
lifuzu / Makefile
Created February 4, 2014 07:11 — forked from xuhdev/Makefile
Makefile template
# Makefile template for shared library
CC = gcc # C compiler
CFLAGS = -fPIC -Wall -Wextra -O2 -g # C flags
LDFLAGS = -shared # linking flags
RM = rm -f # rm command
TARGET_LIB = libtarget.so # target lib
SRCS = main.c src1.c src2.c # source files
OBJS = $(SRCS:.c=.o)
@lifuzu
lifuzu / trim.bash
Created February 4, 2014 18:53
trim string the leading and trailing whitespaces
trim() {
local var=$@
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
trim " abc ";
@lifuzu
lifuzu / dependencies.gradle
Created February 10, 2014 21:07
collect application dependencies
task collectJars(type: Copy){
into "$buildDir/output/lib"
from configurations.testRuntime
}
//After running
gradle collectJars
@lifuzu
lifuzu / build.gradle
Created February 10, 2014 23:36 — forked from sebersole/build.gradle
Custom gradle pom xml
pom.withXml {
def root = asNode();
root.appendNode( 'url', 'http://hibernate.org' )
def org = root.appendNode( 'organization' )
org.appendNode( 'name', 'Hibernate.org' )
org.appendNode( 'url', 'http://hibernate.org' )
def jira = root.appendNode( 'issueManagement' )
jira.appendNode( 'system', 'jira' )
jira.appendNode( 'url', 'https://hibernate.atlassian.net/browse/HHH' )
}
@lifuzu
lifuzu / gist.gradle
Created February 10, 2014 23:37 — forked from bajtos/gist.gradle
custom gradle pom xml
pom.withXml {
def root = asNode()
def deps = new Node(root, 'dependencies')
configurations.compile.allDependencies.each { dep ->
def node = new Node(deps, 'dependency')
new Node(node, 'groupId', dep.group)
new Node(node, 'artifactId', dep.name)
new Node(node, 'version', dep.version);
}
}
@lifuzu
lifuzu / prop.gradle
Created February 12, 2014 02:32
read/write properties file
//You could do it using the java syntax, e.g.:
Properties props = new Properties()
props.load(new FileInputStream("/path/file.properties"))
//This should work in any groovy script. There might be a more "groovy" way of doing it though, using closures or some other fancy shortcut.
@lifuzu
lifuzu / gist:8970067
Created February 13, 2014 05:10 — forked from stran12/gist:1394757
How to install cGit on Nginx

How to install cGit on Nginx (Ubuntu server)

Step-by-step installtion of cGit on nginx without funky rewrite rules.

Pre-requisites

This is for :

@lifuzu
lifuzu / dependencies.gradle
Created February 13, 2014 07:07
Gradle task dependencies relationship
task snth << {
println "************************* before"
}
task aoeu << {
println "**************************** during aoeu"
}
publish.dependsOn(aoeu)
@lifuzu
lifuzu / set.coffee
Created February 13, 2014 21:50 — forked from jwreagor/set.coffee
class window.Set
constructor: (array) ->
if not array
@values = []
else
if array.constructor is Set
return new Set array.values
if array.constructor is Array
{_} = require 'underscore'
child_process = require 'child_process'
async = require 'async'
healthCheckInterval = 60 * 1000
bounceInterval = 60 * 1000
bounceWait = bounceInterval + 30 * 1000
delayTimeout = (ms, func) -> setTimeout func, ms
class MonitoredChild