Skip to content

Instantly share code, notes, and snippets.

setup a clojure project
-------------------------
* Use `mvn archetype:generate` to create a project. (archetype id 845 for sample clojure project)
* add the nrepl dependency
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.nrepl</artifactId>
<version>0.2.0-beta9</version>
</dependency>
Get the md5sum for files in a directory
----------------------------------------
$ ls | xargs md5sum
If the file name contains white space, set the delimiter to new line (default delimiter is white space)
$ ls | xargs -d'\n' md5sum
Estimate the directories / files size
$ ls | xargs du -sh
*
When scp ing a file which has white spaces in its name have to escape twice,
because it's escaped locally and then on the remote end.
There are a couple of options you can do (in bash):
scp user@example.com:"'web/tmp/Master File 18 10 13.xls'" .
scp user@example.com:"web/tmp/Master\ File\ 18\ 10\ 13.xls" .
scp user@example.com:web/tmp/Master\\\ File\\\ 18\\\ 10\\\ 13.xls .
$ echo "abc"
abc
$ echo "abc" | sed 's/b/z/'
azc
$ echo "abcb" | sed 's/b/z/'
azcb
$ echo "abcb" | sed 's/b/z/g'
<%
var carbon = require('carbon');
var server = new carbon.server.Server();
var options = {system: true, domain: carbon.server.tenantDomain() , tenantId: carbon.server.tenantId()};
var dataStore = new carbon.registry.Registry(server, options);
var res;
var mycontent;
var path = "/_system/governance/sen/hello";
try {
res = dataStore.get(path);
mvn -Dmaven.surefire.debug test --> surefire test
mvn versions:set -DnewVersion=2.50.1-M1 --> manually set version
mvn versions:commit --> apply the changes
mvn versions:revert --> revert the changes
mvn -Dmaven.repo.local=$HOME/.my/other/repository clean install
mvn -Dtest=org.my.pkg.Hello#testGreet test
@bsenduran
bsenduran / Sierpinski.java
Created November 10, 2015 18:05
Sierpinski Triangle from Pascal Triangle
public class Sierpinski {
public static void main(String[] args) {
int no_of_row = 50;
int[][] tri = new int[no_of_row][no_of_row];
for (int i = 0; i < no_of_row; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i) {
tri[i][j] = 1;
}
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "usage: sh thread-analyze.sh <pid> <number-of-dumps> <interval>"
exit
fi
count=$2
for i in `seq 1 $count`;
do
jstack -l $1 > thread_dump_`date "+%F-%T"`.txt &
@bsenduran
bsenduran / top-consumers.sh
Last active December 20, 2017 04:41
Analyze the thread usage of a java application and prints the top CPU consuming threads
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "usage: sh top-consumers.sh <pid> <number-of-consumers>"
exit
fi
lowerBound=$(expr "$2" + 1)
jstack -l $1 > top-consumers_thread_dump.txt &
#! /bin/bash
for i in $(seq 1 408)
do
f=seg-$i-v1-a1.ts
# echo $f
wget "<URL>/$f"
cat $f >> all.ts
rm $f
done