Skip to content

Instantly share code, notes, and snippets.

@nrm176
nrm176 / reduce_sample.js
Created September 13, 2015 06:35
Just trying to get used to how Gist works...
var nums = [1,2,3,4,5]
var ans = nums.reduce(function(x,y){
return x+y
})
console.log(ans)
@nrm176
nrm176 / filterAndMap.js
Created September 13, 2015 06:56
Filter numbers larger than or equal to 4 and square them
var m = [1,2,3,4,5].filter(function(e){
if (e>=4){
return e
}
}).map(function(e){
return e*e;
});
console.log(m)
var data = [
{
regionId: 1,
regionName: "Kanto",
prefectures: [
{id: 1, name: "Tokyo", population: 10000},
{id: 2, name: "Kanagawa", population: 20000},
{id: 3, name: "Chiba", population: 300},
{id: 4, name: "Gunma", population: 20}
]
import csv
files = [
"a.csv",
"b.csv",
"c.csv",
"d.csv",
"e.csv"
]
BASE_PATH = "base_path/tobedecided"
@nrm176
nrm176 / MeCab
Created February 2, 2017 02:23
First MeCab example
import MeCab
mecab = MeCab.Tagger("-Ochasen")
print(mecab.parse("今日はいい天気ですね。"))
@nrm176
nrm176 / Simple Moving Average
Created June 24, 2017 04:54
Simple Moving Average
import numpy as np
#mock data
data = '''853 1,005
992 876
589 1,330
1,532 389
1,414 508
1,237 652
'''
Array.from(document.querySelectorAll('div.padT12.marB10.clearFix > table tr td:nth-child(5)')).map((e)=>e.innerText)
@nrm176
nrm176 / gist:8d26ed33903260df7799a10a2e732aa8
Last active November 27, 2018 03:57
Yahooトップページのおすすめタブの画像を取得する
const puppeteer = require('puppeteer');
const moment = require('moment');
const FAKE_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5';
const YAHOO_URL = 'https://www.yahoo.co.jp';
const TARGET_ELEM = ''div#videoFesBoxbd > div#recommendfb > div.lCassette p.thumbnailImg'';

(async () => {
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="d-flex flex-grow-1">
<span class="w-100 d-lg-none d-block"><!-- hidden spacer to center brand on mobile --></span>
<a class="navbar-brand d-none d-lg-inline-block" href="#">
Navbar 6
</a>
<a class="navbar-brand-two mx-auto d-lg-none d-inline-block" href="#">
<img src="//placehold.it/40?text=LOGO" alt="logo">
</a>
<div class="w-100 text-right">
1. Go visit https://folio-sec.com/
2. Copy the following command on Chrome Developer Tool and execute it
```javascript
[].concat.apply([], Array.from(document.querySelectorAll('section.slider.landingPageSlider div.slider__outer')).map((e)=>{ return Array.from(e.querySelectorAll('a.card')).map((e)=>{ var k = Array.from(e.querySelectorAll('h1.card__name > span')).map((e)=>{return e.textContent}).reduce((c,v)=>{return c+v}); var v = e.querySelector('div.card__return > p').textContent; return {'key':k, 'value':v}})}))
```
3. You will get the json like the following: