Skip to content

Instantly share code, notes, and snippets.

@vunb
vunb / A simple cache for Java application.
Last active January 1, 2016 19:39
Although in last our projects we're using more Java and XSLT, we always compare Java and .NET features. It's not a secret that in most applications we may find cache solutions used to improve performance. Unlike .NET providing a robust cache solution Java doesn't provide anything standard. Of course Java's adept may find a lot of caching framewo…
Ref: http://www.nesterovsky-bros.com/weblog/2008/12/04/ASimpleCacheForJavaApplication.aspx
Although in last our projects we're using more Java and XSLT, we always compare Java and .NET features. It's not a secret that in most applications we may find cache solutions used to improve performance. Unlike .NET providing a robust cache solution Java doesn't provide anything standard. Of course Java's adept may find a lot of caching frameworks or just to say: "use HashMap (ArrayList etc.) instead", but this is not the same.
Think about options for Java:
1. Caching frameworks (caching systems). Yes, they do their work. Do it perfectly. Some of them are brought to the state of the art, but there are drawbacks. The crucial one is that for simple data caching one should use a whole framework. This option requires too many efforts to solve a simple problem.
2. Collection classes (HashMap, ArrayList etc.) for caching data. This is very straightforward solution, and very productive. Everyone knows these classes, nothin
@vunb
vunb / node.js
Last active December 31, 2015 23:09
The error is Error: Cannot find module 'express'.
Problem: Seems like npm (now?) installs node modules to /usr/local/lib/node_modules/ and not /usr/local/lib/node/
Solution: sudo ln -s /usr/local/lib/node_modules/ /usr/local/lib/node
OR:
Check NODE_PATH: npm root -g
You can add the following to ~/.bash_profile:
export NODE_PATH=/usr/lib/node_modules:$NODE_PATH
Easy WordPress Parallax Slider
http://wordpress.org/plugins/easy-wp-parallax-slider/
http://demo.oscitasthemes.com/demos/easy-wordpress-parallax-slider/
http://www.velvetinkmedia.com/wp-content/themes/vim/sliders/
http://www.velvetinkmedia.com/wp-content/themes/vim/sliders/parallax/documentation/documentation.html
@vunb
vunb / micoff.sh
Last active December 29, 2015 06:29
Digital Audio Technology
#! /bin/bash
if [ $# -eq 0 ]; then
echo "You have to specify a module index"
exit 128
fi
pactl unload-module $1
@vunb
vunb / mount
Created November 13, 2013 07:52
how to mount .img file on linux?
try to use the -r flag (read-only)
# mount -r -o loop file.img /mnt
if that doesn't work try:
# unsquashfs
@vunb
vunb / mvn-copy-dependencies.sh
Created November 12, 2013 09:55
Maven copy dependencies to lib folder
mvn dependency:copy-dependencies -DoutputDirectory=path/to/lib/folder
@vunb
vunb / install-development-tools.sh
Last active December 28, 2015 02:09
Cài đặt các gói công cụ phát triển, biên dịch: make, gcc, gdb, .... cơ bản là đầy đủ
sudo yum update
sudo yum groupinstall "Development Tools"
sudo yum install kernel-devel kernel-headers
@vunb
vunb / ffmpeg-convert-mp3-to-wave
Created November 7, 2013 04:52
Convert mp3 to wave format using ffmpeg
ffmpeg -i input.mp3 -acodec pcm_s16le -ac 1 -ar 16000 output.wav
# To convert all mp3 files in a directory in Linux:
for f in *.mp3; do ffmpeg -i "$f" -acodec pcm_s16le -ac 1 -ar 16000 "${f%.mp3}.wav"; done
# Or Windows:
for /r %i in (*) do ffmpeg -i %i -acodec pcm_s16le -ac 1 -ar 16000 %i.wav
# 1. Output to Console
# All logging will be redirected to your console.
# Specific properties: PropertyConfigurator.configure("/log4j.properties");
# Root logger option
log4j.rootLogger=INFO, stdout
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
@vunb
vunb / soxConverter.sh
Created November 4, 2013 04:57
Recording voice prompts with Audacity and SOX Ref: http://www.bfrigon.com/custom_voice_prompts/
#!/bin/sh
mkdir -p alaw
mkdir -p ulaw
mkdir -p gsm
mkdir -p wav
mkdir -p sln16
mkdir -p g722