Skip to content

Instantly share code, notes, and snippets.

View noelyahan's full-sized avatar
🏠
Working from home

Noel Yahan noelyahan

🏠
Working from home
View GitHub Profile
@noelyahan
noelyahan / wso2_default_cahe_v0.5.java
Last active August 29, 2015 14:27
Simple cache creation in v0.5 jcache
CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager("sampleCacheManager");
Cache<String, Integer> cache = cacheManager.getCache("sampleCache");
String key = "1";
int value1 = 9876;
cache.put(key, value1);
int value = cache.get(key).intValue();
CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager("test");
String cacheName = "cacheXXX";
cache = cacheManager.<String,Integer>createCacheBuilder(cacheName).setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, 10)).
setStoreByValue(false).build();
int value = 9876;
cache.put(key, value);
assertEquals(cache.get(key).intValue(), value);
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
//CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(new URI("sampleCacheManager"));
Cache<String, Integer> cache = cacheManager.getCache("sampleCache");
String key = "1";
int value1 = 9876;
cache.put(key, value1);
int value = cache.get(key).intValue();
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
//CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(new URI("sampleCacheManager"));
String cacheName = "cacheXXX";
cache = cacheManager.createCache(cacheName, new MutableConfiguration<K, V>()
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, cacheTimeout)))
.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, cacheTimeout)))
.setStoreByValue(false));
int value = 9876;
cache.put(key, value);
assertEquals(cache.get(key).intValue(), value);
# run instructions : python find.py / -m "2015-12-07 21:25:29" 30
import sys
import os
from datetime import datetime, timedelta
TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S";
# file mod info infomation hashmap
rwx_hash = {1:"--x", 2:"-w-", 4:"r--", 3:"-wx", 5:"r-x", 6:"rw-", 7:"rwx"}
# run instructions : python rename_all.py folder_path start_file_prefix
# ex: python rename_all.py /home/xxx/Pictures/my_collection "Garden-"
# output will be "Garden-1.png, Garden-2.png" etc..
import sys
import os
# input arguments folder_path & rename prefix
args = sys.argv
# folder path which files are contains
#include <stdio.h>
#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/flann/miniflann.hpp"
#include <tesseract/baseapi.h>
using namespace cv;
using namespace std;
#include <opencv2/opencv.hpp>
#include <vector>
#include <string>
using namespace std;
using namespace cv;
// Code from: http://www.adp-gmbh.ch/cpp/common/base64.html
static const std::string base64_chars =
@noelyahan
noelyahan / RedisPythonPubSub1.py
Created February 7, 2016 19:13 — forked from jobliz/RedisPythonPubSub1.py
A short script exploring Redis pubsub functions in Python
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@noelyahan
noelyahan / cluster.md
Created February 10, 2016 10:37 — forked from learncodeacademy/cluster.md
Node Cluster - Enhance your node app by using all the cores of your processor.

Here's all you have to do to add clustering to your node.js application.

  • save this code as cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)
  • the only line you'll need to change is the last line - it needs to point to the location of your server.js file
var cluster = require('cluster');

if (cluster.isMaster) {
  // Count the machine's CPUs
 var cpuCount = require('os').cpus().length;