Skip to content

Instantly share code, notes, and snippets.

View greatghoul's full-sized avatar
🏠
Working from home

greatghoul greatghoul

🏠
Working from home
View GitHub Profile
@greatghoul
greatghoul / kaminari.zh-CN.yml
Created March 27, 2014 01:38
kaminari 的简体中文资源文件
zh-CN:
views:
pagination:
first: "« 首页"
last: "末页 »"
previous: "‹ 上页"
next: "下页 ›"
truncate: "…"
helpers:
page_entries_info:
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
#!/usr/bin/env ruby
require 'yaml'
require 'fileutils'
SOURCE_DIR = '/home/greatghoul/Workspace/greatghoul/blog/content/'
TARGET_DIR = '/home/greatghoul/Workspace/blog/_posts/'
def parse_file(filename)
puts "Parsing #{filename}"
@greatghoul
greatghoul / gbkunzip
Created June 25, 2014 06:05
Ubuntu 解压政体中文的 zip 包,避免乱码。简体中文的版本请见 http://lilydjwg.is-programmer.com/posts/16293.html
#!/usr/bin/env python3
# fileencoding=utf-8
'''
解压 zip 文件,其中的文件名是 GB18030 编码,但系统是 Unicode 编码
'''
import sys
import os
from gbzip import ZipFile
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@greatghoul
greatghoul / veakupes.conf
Created August 7, 2014 15:44
rails nginx conf
upstream veakupes {
server unix:/home/wapech/applications/veakupes/current/tmp/pids/unicorn.sock fail_timeout=0;
}
server {
listen 8005;
server_name _;
root /home/wapech/applications/veakupes/current/public;
@greatghoul
greatghoul / questionnaire.rb
Created August 15, 2014 00:29
自定义 ActiveModelCallback
class Questionnaire < ActiveRecord::Base
include Restorable
set_callback :remove, :after, :after_remove
private
def after_remove
self.stop
end
from bs4 import BeautifulSoup
import re
def count(html):
soup = BeautifulSoup(html)
total = 0
for node in soup.find_all(True):
inner_html = "".join([str(x) for x in node.contents])
if node.name and re.match('^\\s*$', inner_html):

title: Introduce Remarks theme: gdg name: inverse layout: true class: inverse


class: center middle

Remarks

@greatghoul
greatghoul / Makefile
Created February 6, 2015 15:11
SAE Python Webapp Makefile
#!/bin/bash
PKG_FILE=site/site-packages.zip
install:
@echo '-- Install development dependencies'
pip install -r requirements-dev.txt
@echo '-- Install runtime dependencies'
saecloud install -r requirements.txt
@echo '-- Package dependencies to site/site-packages.zip'