Skip to content

Instantly share code, notes, and snippets.

View nukosuke's full-sized avatar
🍊
🐈 🐈 🐈

nukosuke nukosuke

🍊
🐈 🐈 🐈
View GitHub Profile
@nukosuke
nukosuke / kiritsubo.js
Created June 8, 2016 00:02
node.jsでKyokoさんに源氏物語1章を朗読してもらう
var client = require('cheerio-httpcli');
var execSync = require('child_process').execSync;
client.fetch('http://attic.neophilia.co.jp/aozora/genjimonogatari/htmlfiles/kiritsubo.html', {}, (err, $, res) => {
$('p').each(function(idx) {
$(this)[0].children
.filter(item => item.type === 'text')
.map(item => item.data.replace(/(.+)/g, ''))
.forEach(item => execSync(`say ${item}`));
});
@nukosuke
nukosuke / build_annictjs_document.sh
Created September 25, 2016 14:29
annict.jsのドキュメント生成&公開スクリプト
#!/bin/sh
npm install && \
npm run docs && \
git checkout gh-pages && \
rm -rf classes interfaces assets index.html && \
mv ./docs/* . && \
rmdir docs && \
git add . && \
git commit -m "build $(git describe --abbrev=0 master) document : $(date)" && \
@nukosuke
nukosuke / .travis.yml
Created October 11, 2016 07:19
PHP Travis CI config
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- hhvm
@nukosuke
nukosuke / install-emacs.sh
Created October 12, 2016 21:48
Emacsインストール
#!/bin/sh
brew install --with-cocoa --srgb --with-gnutls emacs
brew linkapps emacs
@nukosuke
nukosuke / get-string-and-split-into-integer.ex
Last active October 20, 2016 03:30
ワンライナーでスペース区切りで表現された数列を標準入力から1行を読み込んで整数値に変換する方法
"" |> IO.gets |> String.trim_trailing |> String.split(" ") |> Enum.map(&String.to_integer(&1))
@nukosuke
nukosuke / pyramid.js
Created October 29, 2016 16:59
co3496558でやってたピラミッド作る問題
function createPyramid(height){
return Array.from({length: height}, (v,k) => k+1)
.map(r => ' '.repeat(height-r).concat('*'.repeat(r*2-1)))
.join('\n');
}
console.log(createPyramid(10));
@nukosuke
nukosuke / server.js
Last active January 26, 2017 04:12
react on rails rendering server using Node.js
// client/node/server.js
// https://github.com/shakacode/react_on_rails/blob/master/docs/additional-reading/node-server-rendering.md
var net = require('net');
var fs = require('fs');
var bundlePath = '../../app/assets/webpack/';
var bundleFileName = 'webpack-bundle.js';
var currentArg;
use IO::Socket::UNIX;
use JSON;
my $SOCK_PATH = "./node.sock";
print $SOCK_PATH;
my $client = IO::Socket::UNIX->new(
Type => SOCK_STREAM(),
Peer => $SOCK_PATH,
) or die $!;
@nukosuke
nukosuke / application.html.erb
Last active February 8, 2017 08:16
react_on_railsとreact-routerでシングルページアプリケーションをサーバサイドレンダリングする ref: http://qiita.com/nukosuke/items/2769b9505617c4b6ee07
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<%= server_render_js("Helmet.rewind().title.toString()") %>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all' %>
</head>
<body>
<%= yield %>
@nukosuke
nukosuke / serverRegistration.js
Created February 8, 2017 08:47
react_on_rails, react-router, redux
import React from 'react';
import { Provider } from 'react-redux';
import { match, RouterContext } from 'react-router';
import ReactOnRails from 'react-on-rails';
import Helmet from 'react-helmet';
import routes from '../routes/routes';
import store from '../store/store';
// for header title server side rendeting on first load
// ref: http://r7kamura.hatenablog.com/entry/2016/10/10/173610