Skip to content

Instantly share code, notes, and snippets.

View shokai's full-sized avatar

Sho Hashimoto shokai

View GitHub Profile
# Description:
# hubot scrapbox notification
#
# Author:
# @shokai <[email protected]>
config =
room: "news"
header: ":sake:"
// pre saveはcreateでも実行される
import mongoose from 'mongoose'
(async () => {
await mongoose.connect('mongodb://localhost/shokai')
const userSchema = mongoose.Schema({
name: {
type: String,
// updateする時に、runValidators: false` だったら、modelの `required: true` はどう動くか
import mongoose from 'mongoose'
(async () => {
await mongoose.connect('mongodb://localhost/shokai')
const userSchema = mongoose.Schema({
name: {
type: String,
// updateする時に、runValidators: false` だったら、modelの `required: true` はどう動くか
import mongoose from 'mongoose'
(async () => {
await mongoose.connect('mongodb://localhost/shokai')
const userSchema = mongoose.Schema({
name: {
type: String,
@shokai
shokai / component.js
Last active April 22, 2016 08:30
subscribe redux store without react-redux
export class Component extends React.Component{
mapState(state){
return state;
}
shouldComponentUpdate(nextProps, nextState){
if(Object.keys(nextState).length !== Object.keys(this.state).length ||
Object.keys(nextProps).length !== Object.keys(this.props).length){
return true;
#!/usr/bin/osascript -l JavaScript
function input(emoji){
var app = Application("System Events");
app.includeStandardAdditions = true;
var currentClipboard = app.theClipboard();
app.setTheClipboardTo(emoji);
app.keystroke("v", {using: "command down"});
delay(1);
app.setTheClipboardTo(currentClipboard);
@shokai
shokai / photoshop-sb.js
Last active March 2, 2016 05:34
マウスを乗せると服が透けるブックマークレット
javascript:(function(){var sty=document.createElement("style");sty.innerHTML="img:hover{-webkit-filter: brightness(0.5) saturate(2) contrast(1.5) !important;}";document.getElementsByTagName("body")[0].appendChild(sty);})();
@shokai
shokai / say-time
Last active February 26, 2016 01:38
Macで時刻を読み上げるコマンド
#!/usr/bin/env ruby
now = Time.now
s = now.min == 0 ? "#{now.hour}時" : "#{now.hour}時#{now.min}分"
cmd = "say #{s} #{ARGV.join ' '}"
puts cmd
system cmd
@shokai
shokai / run-each-packages
Last active January 28, 2016 08:50
run command in each packages of lerna
#!/usr/bin/env node
"use strict";
var path = require("path");
var fs = require("fs");
var spawn = require("child_process").spawn;
var async = require("async");
var pkgs = fs.readdirSync(path.resolve(__dirname + "/../packages/"));
var each = async.eachSeries;
print("start");
function isSpam(page){
if(page.text.trim() === "(empty)") return true;
var desc = page.text
.replace(/\[{2,3}([^\[\]]+)\]{2,3}/g, "")
.replace(/[\n\s\t]/g, "");
if(desc.length < 1) return true; // gyazz-tag 以外に解説文が無ければspam
if(!(/\[\[.+\]\]/.test(page.text))) return true; // 他ページへのリンクが無いページはspam
if(/\n/.test(page.text)) return false; // 本文が2行以上あればok