Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working from home

Noel Yahan noelyahan

:octocat:
Working from home
View GitHub Profile
View wso2_custom_cahe_v1.0.java
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);
@noelyahan
noelyahan / wso2_default_cahe_v0.5.java
Last active Aug 29, 2015
Simple cache creation in v0.5 jcache
View wso2_default_cahe_v0.5.java
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();
View wso2_custom_cahe_v0.5.java
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);
View wso2_default_cahe_v1.0.java
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();
View file_path.py
# 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"}
View rename-all.py
# 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
View my_ocr.cpp
#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;
View opencv_base64.cpp
#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 Feb 7, 2016 — forked from jobliz/RedisPythonPubSub1.py
A short script exploring Redis pubsub functions in Python
View RedisPythonPubSub1.py
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 Feb 10, 2016 — forked from learncodeacademy/cluster.md
Node Cluster - Enhance your node app by using all the cores of your processor.
View cluster.md

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;
You can’t perform that action at this time.