Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>JavaScript Sample</title>
<script>
window.onload = function () {
// DOM 조작하기
let statusNum = 1;
const myParagraph = document.getElementById("my-paragraph");
@golbin
golbin / reddit.py
Last active July 4, 2018 08:00
Get Reddit Articles
import requests
REDIT_URL = 'https://www.reddit.com'
ML_TOP_URL = 'https://www.reddit.com/r/machinelearning/top.json?redditWebClient=mweb2x&layout=classic&raw_json=1&withAds=true&subredditName=machinelearning&sort=top&t=day&feature=link_preview&sr_detail=true&app=2x-client-production'
HEADERS = {'User-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1'}
@golbin
golbin / cnn_rnn_mnist.py
Created April 10, 2017 00:15
MNIST with CNN + RNN
# Python 3, TensorFlow 1.0
import os
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("./mnist/data/", one_hot=True)
#########
@golbin
golbin / mecab-ya.js
Created April 9, 2016 15:21
mecab-ya examples
var mecab = require('mecab-ya');
var text = '아버지가방에들어가신다';
mecab.pos(text, function (err, result) {
console.log(result);
/*
[ [ '아버지', 'NNG' ],
[ '가', 'JKS' ],
[ '방', 'NNG' ],
@golbin
golbin / init.el
Last active August 5, 2016 13:21
dotemacs
(require 'package)
(package-initialize)
(setq package-archives '(("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(require 'helm)
(require 'helm-ag)
(require 'helm-projectile)
(require 'magit)
(require 'yasnippet)
@golbin
golbin / MyDate.js
Last active August 29, 2015 14:26
Get a date of this week with a name of a day
function MyDate (args) {
var MICROSECONDS_OF_A_DAY = 86400000,
today = args ? new Date(args) : new Date(),
daysOfThisSunday = Math.floor(today.getTime() / MICROSECONDS_OF_A_DAY) - today.getDay();
var dayNames = {
SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6
};
return {
var nodeunit = require('nodeunit'),
promiseFuncs = require(__dirname + '/../index');
exports['Promise unit test'] = nodeunit.testCase({
'success from Q': function (test) {
promiseFuncs.success()
.then(test.ok)
.fail(console.log)
.done(test.done);
@golbin
golbin / function-chain.js
Last active November 24, 2020 00:54
JavaScript Function Chain & Lazy Evaluation
var _ = require('lodash');
var numbers = [1, 2, 3];
var result =
_.map(numbers, function (val) { // numbers를 전부 돌면서 값에 1씩 더해서 새로운 배열을 리턴한다.
return val + 1;
})
.filter(function (val) { // 위에서 생성된 배열에서 값이 2보다 큰 요소만 배열로 만들어서 리턴한다.
return val > 2;
@golbin
golbin / cheat369.js
Last active August 29, 2015 14:22
369 Cheat Script
/*
* 3,6,9 치트 스크립트
* 3,6,9 는 박수, 0에서는 키스, 5에서는 만세.
* 액션을 숫자가 나오는 순서에 맞춰야함. 중복도 쳐야함.
* 예) 43 : :clap:
* 39 : :clap: :clap:
* 50 : :raised_hands: :kiss:
*/
var Cheat369 = {
@golbin
golbin / build_dummy_data.js
Last active August 29, 2015 14:14
MongoDB Generic Index
// 더미 데이터 생성
for (var i = 0; i < 100000; ++i) {
var arr = [];
var size = Math.floor(Math.random() * 10);
for (var j = 0; j < size; ++j) {
var doc = {};
doc["prop" + j] = Math.floor(Math.random() * 1000);
arr.push(doc);
}