Skip to content

Instantly share code, notes, and snippets.

View iwinux's full-sized avatar
👽

Limbo Peng iwinux

👽
View GitHub Profile
@iwinux
iwinux / gist:938151
Created April 23, 2011 01:59
CPU Temperature Widget for Awesome3
-- {{{ shell script: showtemp
-- #! /bin/bash
-- echo "scale=1; `cat /sys/devices/platform/coretemp.0/temp1_input`/1000" | bc
-- }}}
function get_cpu_temp()
local s = io.popen('showtemp')
local temp = s:read()
s:close()
return temp
class Test
class << self
def x
return "X"
end
end
def y
return "Y"
end
#
# /etc/rc.conf - Main Configuration for Arch Linux
#
LOCALE="en_US.UTF-8"
DAEMON_LOCALE="no"
HARDWARECLOCK="localtime"
TIMEZONE="Asia/Shanghai"
KEYMAP="us"
CONSOLEFONT="ter-v20b"
@iwinux
iwinux / rc.lua
Created July 31, 2011 07:29
Awesome Configurations
require("awful") -- Standard awesome library
require("awful.autofocus")
require("awful.rules")
require("beautiful") -- Theme handling library
require("naughty") -- Notification library
beautiful.init("/home/winus/.cache/awesome/themes/zenburn/theme.lua")
terminal = "terminator"
@iwinux
iwinux / setup.sql
Created September 20, 2011 04:34
Set up a database in MySQL
CREATE DATABASE `databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'mypass';
GRANT ALL ON databasename.* TO 'user'@'localhost';
@iwinux
iwinux / dictsort.c
Created October 21, 2011 18:34
字符串字典排序
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 6
#define N 5
/* reverse strcmp to get descending sort */
int cmp(char *s1, char *s2) {
return -strcmp(s1, s2);
@iwinux
iwinux / isort.c
Created October 22, 2011 14:05
通用版的插入排序
/* 指针运算很费脑子 TAT */
void swap(char *s1, char *s2, size_t size) {
int i;
char tmp;
for (i = 0; i < size; i++, s1++, s2++) {
tmp = *s1;
*s1 = *s2;
*s2 = tmp;
@iwinux
iwinux / reader.py
Created November 1, 2011 02:35
Print out GR items' title and url
#! /usr/bin/python
import sys
import json
from HTMLParser import HTMLParser
def main():
if (len(sys.argv) != 2):
print('No filename specified.')
sys.exit(1)
#! /bin/bash
for i in {1..9999}
do
curl http://www.sysulove.com/lovetree/myapp/index.php/Friend/friendPersonalPage/friend_id/$i --cookie "<Paste your browser cookies here>" > $i.html
sleep 0.5
done
@iwinux
iwinux / mongoid_patch.rb
Created November 21, 2011 06:23
add find_by_attribute to Mongoid
module Mongoid
module Finders
# add find_by_xxx to Mongoid
# from https://github.com/mitijain123/mongoid/commit/b28b360b787ba4cd32e5423afcfa3b83574f9df1
def method_missing(method_id, *args, &block)
conditions = {}
bang = false
case method_id.to_s
when /^find_(all|last||first)_?by_([_a-zA-Z]\w*)(!?)$/