Skip to content

Instantly share code, notes, and snippets.

Rain.i cloudrain21

Block or report user

Report or block cloudrain21

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View benchmark-commands.md

Benchmark commands

Producer

Setup

bin/kafka-topics.sh \
  --zookeeper zookeeper.example.com:2181 \
  --create \
@cloudrain21
cloudrain21 / ajax_node_express_array_json_text.js
Created Apr 18, 2016
Ajax client and nodejs express server exchange json and text data
View ajax_node_express_array_json_text.js
// ajax client
$(".download-selected-list").click( function() {
$.ajax( {
type: "post",
url:'http://localhost:3000/ajax-mongo/downloadImagesZip',
contentType: 'application/json', // to server
data: JSON.stringify({"arr":arrSelectedSrc}),
dataType: 'text', // from server
// dataType: 'binary', // from server
@cloudrain21
cloudrain21 / extract_filename_frompath.js
Created Apr 11, 2016
Extract filename only from path
View extract_filename_frompath.js
var fileName = fPath.match(/[-_\w]+[.][\w]+$/i)[0];
var fileName = fPath.split('/').pop();
@cloudrain21
cloudrain21 / mongodb.js
Created Apr 10, 2016
Simple mongodb module
View mongodb.js
var mongoose = require('mongoose'),
Schema = require('mongoose').Schema;
module.exports = (function() {
var defaultUrl = "mongodb://localhost:27017/test";
var url = defaultUrl;
var schemaName = null;
var schemaDef = null;
var docuModel;
@cloudrain21
cloudrain21 / fileinfo.js
Last active Apr 10, 2016
Simple file stat infomation module
View fileinfo.js
var fs = require('fs'),
util = require('util'),
imgsize = require('image-size');
module.exports = (function(){
var supportExt = ["jpg", "jpeg", "png"]; // supported extension array
var dirPath = ""; // directory path
var fileList = []; // file name array
var fileInfo = [{}]; // array of file info object
@cloudrain21
cloudrain21 / serialized_parallelized_callback.js
Last active Apr 8, 2016
Use serialized or parallelized callback in nodejs
View serialized_parallelized_callback.js
// prints text and waits one second
function doSomethingAsync(callback) {
console.log('doSomethingAsync: Wait for one second.');
setTimeout(function() { callback(); }, 1000);
}
// prints text and waits half a second
function doSomethingElseAsync(callback) {
console.log('doSomethingElseAsync: Wait for half a sec.');
setTimeout(function() { callback(); }, 500);
@cloudrain21
cloudrain21 / imagegrid_mixin.scss
Created Mar 20, 2016
sass mixins for image grid
View imagegrid_mixin.scss
$roundness: 20px 0 20px 0;
@mixin clearfix {
&:before,
&:after {
content: '';
display: table;
}
&:after {
clear: both;
@cloudrain21
cloudrain21 / gulpfile.js
Created Mar 19, 2016
gulpfile.js : auto restart & livereload the server with gulp (my 2nd)
View gulpfile.js
'use strict';
var gulp = require( 'gulp' ),
gutil = require( 'gulp-util' ),
fork = require( 'child_process' ).fork,
tinyLr = require( 'tiny-lr' ),
sass = require( 'gulp-ruby-sass' ),
sourcemaps = require('gulp-sourcemaps'),
async = require( 'async' );
@cloudrain21
cloudrain21 / gulpfile.js
Created Mar 19, 2016
gulpfile.js : auto restart & livereload the server with gulp
View gulpfile.js
// webserver 모듈은 public 아래의 contents 를 기준으로
// gulp 기동과 동시에 webserver 및 explorer 까지 띄워준다.
// gulp-livereload 모듈은 sublime-text 의 LiveReload
// 플러그인을 Enable 시키는데 이 때 400 ms 의 delay 를 주면서
// chrome 의 live reload extension 과 통신하여 refresh 하게 한다.
var gulp = require('gulp'),
// jshint = require('gulp-jshint'),
sass = require('gulp-ruby-sass'),
@cloudrain21
cloudrain21 / gist:04d3bd795d46e5f811af
Created Feb 4, 2016
use variable name as another variable's name
View gist:04d3bd795d46e5f811af
# use variable name as another variable's name
foobar="xx"
name=foobar
echo ${!name}
You can’t perform that action at this time.