Skip to content

Instantly share code, notes, and snippets.

Avatar

HIRATA Yasuyuki / 平田 泰行 hirataya

View GitHub Profile
@hirataya
hirataya / hello_world.jsx
Last active Dec 11, 2018
React + i18next
View hello_world.jsx
import React from "react";
import i18n from "path/to/i18n.js";
const HelloWorld = () => {
return(<p>{ i18n.t("hello") }</p>);
}
export default HelloWorld;
View base64
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
View 17sai.user.js
// -*- 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
View rakuten_remove_ads.user.js
// ==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 Oct 20, 2012
Bookmarklet/keyconfig for Tweetbot
View gist:3922024
// 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));
View rvdata2_dump.rb
#! /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
View log
% 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 Jan 29, 2012
Ruby dies with "method `method_missing' called on terminated object"
View log
% 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 Jan 23, 2012
フェイトちゃんちゅっちゅ
View get_uri_title.rb
# -*- coding: utf-8 -*-
require "uri"
require "open-uri"
require "nokogiri"
require "kconv"
class Fatechan::Plugin::GetURITitle
include Cinch::Plugin
listen_to :channel
View cinch-encoding.diff
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})
You can’t perform that action at this time.