Skip to content

Instantly share code, notes, and snippets.

@kjunine
kjunine / result.txt
Created August 27, 2014 12:47
multiple errors in Q.all
running second
err - first: [Error: second] second: undefined
running first
@kjunine
kjunine / test.js
Created July 30, 2014 06:00
Image Handling with gm & GraphicsMagic + ImageMagic
'use strict';
var fs = require('fs'),
path = require('path'),
exec = require('child_process').exec,
_ = require('lodash'),
Bluebird = require('bluebird'),
gm = require('gm');
var readImageInfo = function(filepath) {
@kjunine
kjunine / photo.model.js
Created July 27, 2014 08:08
Photo Model & Service
'use strict';
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var PhotoSchema = new Schema({
type: {
type: String,
enum: ['png', 'jpeg', 'gif']
},
@kjunine
kjunine / push.js
Created July 24, 2014 09:01
GCM Push using node-gcm
'use strict';
var gcm = require('node-gcm'),
Q = require('q'),
config = localrequire.config(),
User = localrequire.service('user');
if (process.env.NODE_ENV === 'production') {
var sender = new gcm.Sender(config.gcm.key);
@kjunine
kjunine / push.js
Created July 24, 2014 01:17
GCM Push with User Notification
'use strict';
var request = require('request'),
Q = require('q'),
config = localrequire.config();
if (process.env.NODE_ENV === 'production') {
var BASE_URI = config.gcm.uri,
PROJECT_ID = config.gcm.project,
@kjunine
kjunine / ImageController.java
Created November 21, 2013 09:39
Image Download with Spring MVC
package image;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
@kjunine
kjunine / CrossOriginResourceSharingFilter.java
Created November 19, 2013 13:00
CrossOriginResourceSharingFilter (using Spring MVC) If you want to handle OPTIONS method, you should use Filter instead of Interceptor.
package utils;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@kjunine
kjunine / API.md
Created October 4, 2013 14:03 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@kjunine
kjunine / PooledHTableFactory.java
Created September 16, 2013 07:24
Using HTablePool with HbaseTemplate.
package sample.utils;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTableInterfaceFactory;
import org.apache.hadoop.hbase.client.HTablePool;
public class PooledHTableFactory implements HTableInterfaceFactory {
@kjunine
kjunine / TestConfig
Created September 9, 2013 09:23
Spring @componentscan Execlude Filter Example
@Configuration
@ImportResource("classpath:/net/kjunine/test.xml")
@PropertySource("classpath:/net/kjunine/test.properties")
@ComponentScan(basePackages = "net.kjunine", excludeFilters = { @Filter(type = FilterType.CUSTOM, value = { SamplePackageFilter.class }) })
public class TestConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}