Skip to content

Instantly share code, notes, and snippets.

View weihanchen's full-sized avatar
🏁

weihanchen weihanchen

🏁
  • Taiwan
View GitHub Profile
@weihanchen
weihanchen / config-database.js
Last active November 19, 2016 00:07
NodeJS_User_Authentication
module.exports = {
'secret': process.env.SECRET_KEY || 'user_auth_demo',
'database': process.env.MONGO_CONNECTION || 'mongodb://username:password@localhost:27017/user_auth_demo'
};
@weihanchen
weihanchen / directives.js
Last active August 9, 2016 12:42
angular formatters and parsers
'use strict';
(function() {
angular.module('notes')
.directive('displayDate', [displayDate])
function displayDate() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attrs, ngModelCtrl) {
@weihanchen
weihanchen / color_definition.js
Created August 9, 2016 12:44
angularjs d3 word cloud
var fill = d3.scale.category20();//define colors
@weihanchen
weihanchen / controllers_focus.js
Created August 10, 2016 01:39
angular input focus
'use strict';
(function() {
angular.module('notes')
.controller('focusController', [focusController])
function focusController() {
var gulp = require('gulp' ),
minifycss = require( 'gulp-minify-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
cache = require('gulp-cache'),
livereload = require( 'gulp-livereload'),
connect = require('gulp-connect'),
ngAnnotate = require( 'gulp-ng-annotate'),
@weihanchen
weihanchen / delete.user.js
Created November 19, 2016 00:17
Nodejs API Test
describe('delete user...', () => {
let resourceUrl;
before(function() {
resourceUrl = usersUrl + '/' + userid;
})
it('should response success when deleting user exist', function(done) {
request.delete(resourceUrl)
.expect(200)
.end(function(err, res) {
res.body.should.have.property('success');
@weihanchen
weihanchen / select-all-controller.js
Created February 17, 2017 04:12
Angular input select all on click
'use strict';
(function() {
angular.module('notes')
.controller('selectAllOnClickController', [selectAllOnClickController])
function selectAllOnClickController() {
var self = this;
self.text = "Click me to select all"
}
})();
@weihanchen
weihanchen / ip_address.sh
Created November 28, 2017 00:58
Ubuntu
# Find ip exclude non usage
$ ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | grep 'Bcast' | grep -v '0.0.0.0' | cut -d: -f2 | awk '{ print $1}'
const arr = [...new Set([1, 2, 3, 3])];
[1, 2, 3]
@weihanchen
weihanchen / index_id_aggs.js
Last active January 17, 2018 05:37
elasticsearch
GET logs*/_search
{
"aggs": {
"customerPhoneNo": {
"terms": {
"field": "customerPhoneNo",
"size": 10000,
"include": ["00000000", "0423382656"]
},
"aggs": {