This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rmagick' | |
if ARGV.length < 2 | |
puts "Usage: #{$PROGRAM_NAME} <logo path> <background color>" | |
exit | |
end | |
logopath = ARGV[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
@two_chars_words = %w"朱砂 天下 杀伐 人家 韶华 风华 繁华 血染 墨染 白衣 素衣 嫁衣 倾城 孤城 空城 旧城 旧人 伊人 心疼 春风 古琴 无情 迷离 奈何 断弦 焚尽 散乱 陌路 乱世 笑靥 浅笑 明眸 轻叹 烟火 一生 三生 浮生 桃花 梨花 落花 烟花 离殇 情殇 爱殇 剑殇 灼伤 仓皇 匆忙 陌上 清商 焚香 墨香 微凉 断肠 痴狂 凄凉 黄梁 未央 成双 无恙 虚妄 凝霜 洛阳 长安 江南 忘川 千年 纸伞 烟雨 回眸 公子 红尘 红颜 红衣 红豆 红线 青丝 青史 青冢 白发 白首 白骨 黄土 黄泉 碧落 紫陌" | |
@four_chars_words = %w"情深缘浅 情深不寿 莫失莫忘 阴阳相隔 如花美眷 似水流年 眉目如画 曲终人散 繁华落尽 不诉离殇 一世长安" | |
@sentence_model = %w"xx,xx,xx了xx。 xxxx,xxxx,不过是一场xxxx。 你说xxxx,我说xxxx,最后不过xxxx。 xx,xx,许我一场xxxx。 一x一x一xx,半x半x半xx。 你说xxxxxxxx,后来xxxxxxxx。 xxxx,xxxx,终不敌xxxx。" | |
def get_sentence | |
model = @sentence_model.sample(1)[0].clone | |
while model.include?'xxxx' | |
model.sub!(/xxxx/, @four_chars_words.sample(1)[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <glib.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
// MyJIT homepage: http://myjit.sourceforge.net/index.htm | |
#include "myjit/jitlib.h" | |
struct string_builder{ | |
GString *gstring; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/runtime.h> | |
#import <objc/message.h> | |
// copied from http://stackoverflow.com/questions/17346046/advice-on-how-to-catch-attempt-to-insert-nil-object-from-a-device-needed | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wundeclared-selector" | |
static id safe_initWithObjects(id self, SEL _cmd, const id objects[], const id <NSCopying> keys[], NSUInteger count) { | |
id orignialResult = nil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
require 'msgpack' | |
if ARGV.length < 2 | |
puts "#{$PROGRAM_NAME} <json file> <msgpack file>" | |
exit 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
json_file = ARGV[0] | |
if json_file == nil | |
puts "Usage: #{$PROGRAM_NAME} <json file> [out_file]" | |
exit | |
end | |
require 'json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.length < 2 | |
puts "Usage: #{$PROGRAM_NAME} <plist_file> <json_file>" | |
exit 1 | |
end | |
plist_file = ARGV[0] | |
json_file = ARGV[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# https://en.wikipedia.org/wiki/UTF-8 | |
def unicode2utf8(str) | |
num = str.to_i(16) | |
c1 = 0xE0 + ((num & 0xF000) >> 12) | |
c2 = 0b10000000 + ((num & 0x0FC0) >> 6) | |
c3 = 0b10000000 + (num & 0x003F) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js';(d.head||d.documentElement).appendChild(s)})(document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function func2hex(func) | |
return (string.dump(func):gsub(".", function(c) return ("%02X"):format(c:byte()) end)); | |
end | |
function hex2func(hex) | |
return loadstring(hex:gsub("..", function(x) return string.char(tonumber(x, 16)) end)) | |
end |