Skip to content

Instantly share code, notes, and snippets.

View YuheiNakasaka's full-sized avatar
💭
😇

YuheiNakasaka YuheiNakasaka

💭
😇
View GitHub Profile
@YuheiNakasaka
YuheiNakasaka / get_tweet_events.html
Created July 15, 2014 04:45
Tweet buttonのツイートイベントを取得する
<html>
<head>
<title>Tweet buttonのツイートイベントを取得する</title>
</head>
<body>
<!--ツイートボタン-->
<a href="https://twitter.com/share" class="twitter-share-button" data-via="razokulover" data-lang="ja">ツイート</a>
<script type="text/javascript" charset="utf-8">
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@YuheiNakasaka
YuheiNakasaka / tempfile_test.rb
Created March 5, 2014 02:03
Rails4.0.1,Ruby1.9.3のとあるメソッド内にて、Tempfileでcloseしなくてもあとでまとめてdeleteすればいいかと思ってこんなコードを書いたらtempfileに何も書き込まれてなくてはまった...
require 'tempfile'
chars = (('a'..'z').to_a + ("A".."Z").to_a + (0..9).to_a ) * 1000
words = [chars.join()] * 11
files = []
paths = []
words.each do |word|
file = Tempfile.new(['hoge','jpg'], :encoding => 'ascii-8bit')
file.write(word)
files << file
paths << file.path
@YuheiNakasaka
YuheiNakasaka / workshop.md
Created November 1, 2013 08:34
社内ワークショップ2013。gistdeckを使用して発表。

「師弟登壇・新米サムライの集い 2013」の共有

http://kiban.doorkeeper.jp/events/5291

アジェンダ

  • 「師弟登壇・新米サムライの集い 2013」とは
  • 各社プレゼンの共有(かいつまんでお話)
  • ピックアップ
'Way\Generators\GeneratorsServiceProvider'
@YuheiNakasaka
YuheiNakasaka / searchinko.rb
Last active December 15, 2015 02:29
指定されたURL先の文章に含まれる単語の個数を数える。 ruby seachinko.rb [URL] [検索したい単語] 例) $ruby searchinko.rb http://ja.wikipedia.org/wiki/%E3%83%81%E3%83%B3%E3%82%B3 ちんこ 実行結果:「チンコ - Wikipedia」の中に、「ちんこ」という文字が2個ありました。
#-*- coding: utf-8 -*-
require 'open-uri'
class Searchinko
def initialize(word)
@search_word = word
end
def getTitle(contents)
contents =~ /<title>(.*?)<\/title>/
return $1
@YuheiNakasaka
YuheiNakasaka / mdd.txt
Created August 10, 2012 08:32
ももクロ駆動開発とは
ももクロ駆動開発 (ももくろくどうかいはつ、momoclo-driven development; MDD) とは、
プログラム開発手法の一種で、プログラムに必要な各機能について、最初にももクロを聞き(これをももクロファーストと言う)、
そのももクロが動作する必要最低限な実装をとりあえず行った後、コードを洗練させる、という短い工程を繰り返すスタイルである。
多くのアジャイルソフトウェア開発手法、例えばエクストリーム・プログラミングにおいて強く推奨されている。近年はももクロZ駆動開発へと発展を遂げている。
#-*- coding: utf-8 -*-
#ブラックジャックゲーム
#手札の数字を21に近づけた方の勝ち。
#カードがはじめに1枚配られる。そのあと2回までカードを引くことができる。
#パスあり。パスする時はpassと入力する。
mycard = []
cmpcard = []
#手札を配る
card = (1..13).to_a
@YuheiNakasaka
YuheiNakasaka / parity.rb
Created May 28, 2012 20:06
class Parity
#parity.rb
class Parity
def initialize(num)
@bnum = num.to_s(2)
@counta = 0
0.upto(@bnum.length) do |i|
if @bnum[i] == "1"
@counta += 1
end
@YuheiNakasaka
YuheiNakasaka / faraday.md
Created May 24, 2012 04:54 — forked from rummelonp/faraday.md
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた