Skip to content

Instantly share code, notes, and snippets.

View masapico's full-sized avatar
💭
😊

masapico masapico

💭
😊
  • Japan
View GitHub Profile
@masapico
masapico / file0.txt
Last active February 26, 2016 16:02
Win & Python3 & Atom 環境での文字化け対策ワンライナー ref: http://qiita.com/arakanema/items/c75cf548f796f1caba5f
process.env.PYTHONIOENCODNG = "utf-8";
# Display bytes in String
puts "- utf-8 ------------------------------"
'あ'.bytes { |b| puts "#{b.to_s(16)} => #{sprintf("%#010b", b)}" }
puts "- sjis ------------------------------"
'あ'.encode("Windows-31J").bytes { |b| puts "#{b.to_s(16)} => #{sprintf("%#010b", b)}" }
puts "- utf-16le ---------------------------"
'あ'.encode("utf-16le").bytes { |b| puts "#{b.to_s(16)} => #{sprintf("%#010b", b)}" }
# TrueTypeフォントより登録用のモノクロビットマップ 256x256 を抽出
from PIL import Image, ImageDraw, ImageFont
# path to *.ttf
ttf_path = './EUDC.TTF'
# 抽出したいコードポイント E000 to F2B3
cp_start = 57344
cp_end = 62131
# coding: utf-8
File.open("hoge.txt", "w:utf-16le") do |output|
#-----------------------------------------------------
# added BOM for handling NIHONGO file
output.print [0xfffe].pack("U")
#-----------------------------------------------------
7.times do |i|
@masapico
masapico / gist:2779054
Created May 24, 2012 02:16
JavaScript unicode codepoint....
var util = require("util");
util.puts("\u0041"); // "A"
var codePoint = "A".charCodeAt(0);
util.puts(codePoint.toString(16)); // "41"
@masapico
masapico / gist:1759228
Created February 7, 2012 11:26
Ruby: SQLite3 insert binary
require "sqlite3"
db = SQLite3::Database.new("test.sqlite3")
sql = <<SQL
create table test(
content blob
)
SQL
db.execute_batch(sql)
@masapico
masapico / gist:1759063
Created February 7, 2012 10:44
Ruby Configuration pattern...
# Hash
class MyClass
def initialize
@config = {
name: "default name",
mail: "default mail"
}
end
def set_config