Skip to content

Instantly share code, notes, and snippets.

@cloudrain21
cloudrain21 / git.migrate
Created June 16, 2020 03:22 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@cloudrain21
cloudrain21 / benchmark-commands.md
Created March 26, 2020 03:39 — forked from ueokande/benchmark-commands.md
Kafka Benchmark Commands

Benchmark commands

Producer

Setup

bin/kafka-topics.sh \
  --zookeeper zookeeper.example.com:2181 \
  --create \
@cloudrain21
cloudrain21 / ajax_node_express_array_json_text.js
Created April 18, 2016 21:07
Ajax client and nodejs express server exchange json and text data
// 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 April 11, 2016 21:15
Extract filename only from path
var fileName = fPath.match(/[-_\w]+[.][\w]+$/i)[0];
var fileName = fPath.split('/').pop();
@cloudrain21
cloudrain21 / mongodb.js
Created April 10, 2016 09:35
Simple mongodb module
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 April 10, 2016 09:31
Simple file stat infomation module
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 April 8, 2016 23:10
Use serialized or parallelized callback in nodejs
// 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 March 20, 2016 02:49
sass mixins for image grid
$roundness: 20px 0 20px 0;
@mixin clearfix {
&:before,
&:after {
content: '';
display: table;
}
&:after {
clear: both;
@cloudrain21
cloudrain21 / gulpfile.js
Created March 19, 2016 17:28
gulpfile.js : auto restart & livereload the server with gulp (my 2nd)
'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 March 19, 2016 17:26
gulpfile.js : auto restart & livereload the server with gulp
// 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'),