Skip to content

Instantly share code, notes, and snippets.

View lulalala's full-sized avatar

lulalala lulalala

View GitHub Profile
<剩下><集數><ComicMarket><屬性><語言>
delete [comic] [Comic] [漫畫] [漫画] * (\(?同人誌\)?) 同人誌 [同人] [日文] (同人CG集)
delete [H-COMIC] [同人] [日文] (同人CG集) * (?i)\[[h][-_\s]?comic\] * (?i)\[h漫\]
delete (一般コミック) (成年コミック) (成年コミック・雑誌) (成年コミック.雑誌) (エロ)
delete [PNG]
delete * \[全.冊\] * \(全\d*集\)
delete * \[\d*p\]
delete (同人誌)
replace <語言> [中] [C] (中文) * (\[中.\]) (繁體) [BIG5] [日翻中] @最果ての神狐漢化 * @?悠月工房 * \[[^\]]*?漢化[^\]]*?\] * \[?中文[化版]?\]? * [\(\[]?漢化[\]\)]? [大山文化]
replace <語言> [英] (英) [ENG] [FAKKU] (English)
@lulalala
lulalala / BorderboxModelHolyGrailLayout.html
Created July 6, 2011 03:33
Simplication of The Holy Grail of Layouts using Border-box model
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The Holy Grail of Layouts: Example #1: A List Apart (Using Border-box model)</title>
<style type="text/css">
body {
min-width: 550px; /* prevent narrow window from breaking layout */
}
div {
@lulalala
lulalala / gist:3214537
Created July 31, 2012 07:38
rest-more facebook error
client = RestCore::Facebook.new(app_id: FACEBOOK_APP_ID, secret: FACEBOOK_APP_SECRET)
client.post("1234567/feed", params: post_params)
# error:
# RestCore::Facebook::Error::InvalidAccessToken: {"error"=>{"message"=>"(#200) This API call requires a valid app_id.", "type"=>"OAuthException", "code"=>200}} from https://graph.facebook.com/1234567/feed
@lulalala
lulalala / nginx.conf
Created August 3, 2012 08:01
For http://serverfault.com/questions/405264/ ,having problem using try_files
worker_processes 20;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@lulalala
lulalala / image_folder_partition
Created August 10, 2012 10:12
Partitions numeric folders into 3 hierarchy
# Place under the same folder where the many folders exists, then run the script.
# This will convert folders like 12345678\ to 012\345\678\
require 'fileutils'
Dir.glob("*") do |f|
if not FileTest.directory?(f)
next
end
@lulalala
lulalala / URI param parsing
Created August 14, 2012 06:56
How to append a parameter into the url in Ruby?
u = URI.parse("http://example.com/user/1234?a=1&b=2")
# <URI::HTTP:0x007fe3d9a1f238 URL:http://example.com/user/1234?a=1&b=2>
query = u.query #"a=1&b=2"
query = query << "&c=3"
u.path #"/user/1234"
u.to_s #"http://example.com/user/1234?a=1&b=2"
u.merge(query).to_s #"http://example.com/user/a=1&b=2&c=3" WHY DOES 1234 disappear?!
# I want to get http://example.com/user/1234?a=1&b=2&c=3"
@lulalala
lulalala / reset_change_bug
Created August 16, 2012 07:34
Need to reset change twice for it to be marked unchanged
>> t = Topic.find(47083); time = t.event.end
Topic Load (9.2ms) SELECT `topics`.* FROM `topics` WHERE `topics`.`id` = 47083 LIMIT 1
Topic::Event Load (0.5ms) SELECT `periods`.* FROM `periods` WHERE `periods`.`type` IN ('Topic::Event') AND `periods`.`owner_id` = 47083 AND `periods`.`owner_type` = 'Topic' LIMIT 1
=> Thu, 16 Aug 2012 09:00:04 CST +08:00
>> t.event.changed?
=> false
>> t.event.end = time + 1.second
=> Thu, 16 Aug 2012 09:00:05 CST +08:00
>> t.event.end_changed?
=> true
@lulalala
lulalala / ender_duplicate_remove
Created August 16, 2012 08:18
Remove duplicate ender
set = Set.new()
i = 0
Delayed::Job.order('id DESC').where('queue = "ender"').find_each do |d|
if not (set.add?( d.handler[/\d+/].to_i ))
d.destroy
i += 1
end
end
@lulalala
lulalala / gist:3377911
Created August 17, 2012 10:50
Update pacman
pacman -S gnupg
pacman -Sy
pacman -S systemd-tools --force
pacman -S pacman --force
sudo pacman-key --init; sudo pacman-key --populate archlinux
@lulalala
lulalala / gist:3607450
Created September 3, 2012 06:56
Mysql nested query slower than two distinct query
SELECT `topics`.* FROM `topics` WHERE `topics`.`id` IN (
SELECT DISTINCT `topic_comments`.`topic_id` FROM `topic_comments` WHERE (created_at > '2011-11-08 04:56:58') ORDER BY `topic_comments`.`created_at` DESC)
LIMIT 10 OFFSET 0;
SELECT DISTINCT `topic_comments`.`topic_id` FROM `topic_comments` WHERE (created_at > '2011-11-08 04:56:58') ORDER BY `topic_comments`.`created_at` DESC;
select topics.* from topics where topics.id in (45756,45334,44759,44799,44769,44697,43755,43445,43591,43754,42620,42643,42683,41333,42277,41678,41868,41610,41530,525,41336,41066,41067,41068,40596,40800,40575,40264,40292,40038,39744,39348,40082,39859,39702,40039,39532,38440,38658,8346,38218,37760,33297,37123,37353,37002,37089,36948,36870,36617,36727,16621,25468,25465,16972,8741,9604,17498,14175,14898,26513,26143,26058,10957,8799,35054,36728,36430,36393,36395,35816,7642,36278,36279,36097,24377,33299,35087,35053,32413,34660,34489,34510,33823,34077,33873,33557,32656,32600,33123,30970,32880,32924,116,29133,32274,32409,32104,32148,30