Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

const async = require('async');
const bcrypt = require('bcrypt');
const MongoClient = require('mongodb').MongoClient;
const NAME = 'mockuser';
const PWD = 'mockpwd';
const NUM = 5;
const URL = 'mongodb://localhost:27017/myApp';
const USERS = 'users';
const FOLDERS = 'folders';
@luchoching
luchoching / 1-6.c
Created December 17, 2016 15:25
(My solution) 1.6: Write a program to print the value of EOF : http://stackoverflow.com/questions/1782080/what-is-eof-in-the-c-programming-language
#include <stdio.h>
int main()
{
int value;
int value2;
value = getchar();
value2 = value != EOF;
@luchoching
luchoching / new_sbt.sh
Created July 19, 2016 10:32
Create a new sbt project layout
_sbtnew(){
mkdir -p $1/project
cd $1
echo 'sbt.version = 0.13.11' > project/build.properties
cat << _EOF_ > build.sbt
name := "$1"
version := "1.0"
scalaVersion := "2.11.8"
_EOF_
@luchoching
luchoching / csv_to_string.scala
Created May 27, 2016 10:31
csv to string : aa,bb,cc,dd --> 'aa','bb','cc'
import java.io._
val pw = new PrintWriter(new File("hello.txt" ))
val lines = "'"+Source.fromFile("power-users-list.csv").getLines.toList.mkString("','")+"'"
pw.write(lines)
pw.close
@luchoching
luchoching / .aliases
Last active May 22, 2020 18:38
aliases
alias c="clear"
alias so="source ~/.zshrc"
alias rm='rm -i'
alias rmr='rm -rf'
alias srmr='sudo rm -rf'
alias df='df -h'
alias wget='wget -c' #Continue getting a partially-downloaded file
alias mkdir='mkdir -pv'
alias date='date +"%Z %Y-%m-%d %A %T"'
alias cd..='cd ..'
@luchoching
luchoching / mgo-json-http.go
Last active July 31, 2018 12:47
Golang mgo REST json example
package main
import (
"encoding/json"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"net/http"
)
type Person struct {
@luchoching
luchoching / Hello.jsx
Created May 7, 2015 05:23
ES6 + react + webpack
import React from 'react';
let Hello = React.createClass({
render(){
return(
<div>
<h1>Hello 贊啦!!</h1>
</div>
);
@luchoching
luchoching / .vimrc
Last active August 29, 2015 14:18
my .vimrc
set nocompatible
" Vundle
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/vundle'
Plugin 'altercation/vim-colors-solarized'
Plugin 'godlygeek/tabular'
var Immutable = require('immutable');
var arr = ['a', 'b', 'c'];
var o = Immutable.List(arr);
console.log(o); //List [ "a", "b", "c" ]
console.log(typeof o); //object
console.log(JSON.stringify(o)); //["a","b","c"]
@luchoching
luchoching / indexOf.js
Created March 27, 2015 05:38
Array.indexOf
var a = {x:1, y:2};
var b = {x:3, y:4};
var arr = [a, b];
console.log(arr.indexOf(a)); //0
console.log(arr.indexOf({x:1, y:2})); //-1