Skip to content

Instantly share code, notes, and snippets.

View hirataya's full-sized avatar

Hirata Yasuyuki / 平田泰行 hirataya

View GitHub Profile
@hirataya
hirataya / hello_world.jsx
Last active December 11, 2018 05:54
React + i18next
import React from "react";
import i18n from "path/to/i18n.js";
const HelloWorld = () => {
return(<p>{ i18n.t("hello") }</p>);
}
export default HelloWorld;
perl -e 'undef $/; $_ = <>; $p = (3 - (length)%3)%3; $_ = pack "u", $_; s/^.//mg; tr|` -_|AA-Za-z0-9+/|; s/A{$p}\n$/"="x$p."\n"/se; print' somefile
// -*- coding: utf-8 -*-
// ==UserScript==
// @name They are all 17 years old
// @author HIRATA Yasuyuki <yasu@asuka.net>
// @namespace http://yasu.asuka.net/
// @version 1.1.0
// @include http://www.google.tld/search?*
// @include https://www.google.tld/search?*
// @released 2013-04-23
// @updated 2013-04-30
// ==UserScript==
// @name Rakuten - Remove Ads
// @version 1.0
// @namespace http://yasu.asuka.net/
// @include http://search.rakuten.co.jp/*
// @description 楽天市場の検索画面に出る広告を削除する
// ==/UserScript==
(function() {
ads = document.getElementById("adsDisplayArea");
@hirataya
hirataya / gist:3922024
Created October 20, 2012 04:35
Bookmarklet/keyconfig for Tweetbot
// bookmarklet
javascript:window.location='tweetbot:///post?text=Browsing%3A%20%22'
+encodeURIComponent(document.title)+'%22%20'+encodeURIComponent(encodeURI(window.location.href));
// keyconfig
loadURI('tweetbot:///post?text=Browsing%3A%20%22' + encodeURIComponent(window._content.document.title)+'%22%20' + encodeURIComponent(window._content.location.href));
@hirataya
hirataya / rvdata2_dump.rb
Created February 17, 2012 12:17
rvdata2 dumper
#! /usr/bin/env ruby
require "zlib"
fp = File.open(ARGV.shift, "r:binary")
Marshal.load(fp.read).each.with_index do |cont, index|
id, name, code = cont
code = Zlib::Inflate.inflate(code).force_encoding("utf-8")
puts "#"*79 if 0 < index
printf "[%s] (%d)\n%s", name, id, code
% ruby ragnarok_items.rb > log.txt
ragnarok_items.rb:14:in `block in initialize': NotImplementedError: method `method_missing' called on terminated object (0x00000100d93018 flags=0x0 klass=0x0): SELECT "items".* FROM "items" WHERE (regex(name_iro, 'Battle Axe')) (ActiveRecord::StatementInvalid)
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:321:in `call'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:321:in `block in create_function'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:108:in `call'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:108:in `step'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:108:in `block in each'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:107:in `loop'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:107:in `each'
from /opt/loc
@hirataya
hirataya / log
Created January 29, 2012 16:10
Ruby dies with "method `method_missing' called on terminated object"
% ruby ragnarok_items.rb > log.txt
ragnarok_items.rb:14:in `block in initialize': NotImplementedError: method `method_missing' called on terminated object (0x00000101cf7018 flags=0x0 klass=0x0): SELECT "items".* FROM "items" WHERE (regex(name_iro, 'Battle Axe')) (ActiveRecord::StatementInvalid)
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:321:in `call'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:321:in `block in create_function'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:108:in `call'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:108:in `step'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:108:in `block in each'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:107:in `loop'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/statement.rb:107:in `each'
from /opt/loc
@hirataya
hirataya / get_uri_title.rb
Created January 23, 2012 09:47
フェイトちゃんちゅっちゅ
# -*- coding: utf-8 -*-
require "uri"
require "open-uri"
require "nokogiri"
require "kconv"
class Fatechan::Plugin::GetURITitle
include Cinch::Plugin
listen_to :channel
@hirataya
hirataya / cinch-encoding.diff
Created December 28, 2011 17:11
Cinch quick fix
diff --git a/lib/cinch/utilities/encoding.rb b/lib/cinch/utilities/encoding.rb
index 2a248e2..a4d1bcb 100644
--- a/lib/cinch/utilities/encoding.rb
+++ b/lib/cinch/utilities/encoding.rb
@@ -17,7 +17,7 @@ module Cinch
string.force_encoding("CP1252").encode!("UTF-8", {:invalid => :replace, :undef => :replace})
end
else
- string.force_encoding(encoding).encode!({:invalid => :replace, :undef => :replace})
+ string.force_encoding(encoding).encode!("UTF-8", {:invalid => :replace, :undef => :replace})