Skip to content

Instantly share code, notes, and snippets.

View newmind's full-sized avatar
🎯
Focusing

JG newmind

🎯
Focusing
View GitHub Profile
@newmind
newmind / NumberOfDiscIntersections.py
Last active October 24, 2017 16:36
1. NumberOfDiscIntersections - Compute the number of intersections in a sequence of discs.
# 0% performance :(
# https://codility.com/demo/results/trainingWE5DFA-V3D/
def solution(A):
# write your code in Python 2.7
N = len(A)
result = 0
for i in range(N-1):
for j in range(i+1, N):
@newmind
newmind / getAllSizeOfSite.js
Created September 8, 2016 07:47
Get bson size of all collection os selected site in MongoDB
// get total document size of specific site
var siteId = 'gE9CzFWD8XnNtTYhk'; // daviznote
var totalBson = 0;
var collections = db.getCollectionNames();
collections.forEach(function(collection) {
var collectionSize = 0;
var docs = db.getCollection(collection).find({_siteId:siteId});
docs.forEach(function(doc) {
collectionSize += Object.bsonsize(doc);
});
@newmind
newmind / phantom_ex.js
Last active July 19, 2016 09:20
capture blog to png with phantom
var webpage = require('webpage');
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
const urls = [
'http://blog.naver.com/mantto2/220762528079',
'http://theyoung2002.blog.me/220764384091',
@newmind
newmind / history_navigation.js
Created April 7, 2016 05:21 — forked from tbtlr/history_navigation.js
A simple JavaScript that lets you use your browser's back/forward buttons for in-page navigation by adding custom 'next' and 'previous' events to the window object.
/*
* Lets you use your browser's back/forward buttons for in-page navigation by
* adding custom 'next' and 'previous' events to the window object.
*
* Copyright (c) 2011 Tobias Schneider <schneider@jancona.com>
* This script is freely distributable under the terms of the MIT license.
*
* Example:
*
* window.addEventListener('next', function(){
@newmind
newmind / elb-nodejs-ws.md
Created March 11, 2016 06:20 — forked from obolton/elb-nodejs-ws.md
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@newmind
newmind / ddp-login-with-token.js
Created February 29, 2016 07:05
ddp-login.js
// export METEOR_TOKEN=$(ddp-login --host 54.238.200.77 \
// --port 9000 \
// --env METEOR_TOKEN \
// --method account \
// --retry 5)
var DDP = require('ddp');
var login = require('ddp-login');
var ddpClient = new DDP({
@newmind
newmind / jsonToCSV.js
Created February 22, 2016 07:17
jsontoCSV.js
// jsonToCSV.js
var request = require("request");
var csvWriter = require('csv-write-stream');
var fs = require('fs');
var u = require('underscore');
var url = "http://www.deadfrogstudios.com/appdata/pocketkpi/multiple-dashboard-sparklinev2.json";
request({
url: url,
@newmind
newmind / gist:12daa3892074a6b5c886
Created February 13, 2016 00:23 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
var test = 0;
// note : JS file 로드시 초기에 한번 호출 됩니다. 본인의 이름 혹은 닉네임 리턴 해주시면 됩니다.
var GetName = function () {
return "jgkim";
}
var LOG = false;
function Log(params) {
if (LOG) {
@newmind
newmind / .ideavimrc
Created December 10, 2015 01:54
jetbrain ideaVim shift key apply
nmap <S-Up> v<Up>
nmap <S-Down> v<Down>
nmap <S-Left> v<Left>
nmap <S-Right> v<Right>
vmap <S-Up> <Up>
vmap <S-Down> <Down>
vmap <S-Left> <Left>
vmap <S-Right> <Right>
imap <S-Up> <Esc>v<Up>
imap <S-Down> <Esc>v<Down>