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
-- {{{ 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 |
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
class Test | |
class << self | |
def x | |
return "X" | |
end | |
end | |
def y | |
return "Y" | |
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
# | |
# /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" |
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
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" |
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
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'; |
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 <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); |
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
/* 指针运算很费脑子 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; |
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/python | |
import sys | |
import json | |
from HTMLParser import HTMLParser | |
def main(): | |
if (len(sys.argv) != 2): | |
print('No filename specified.') | |
sys.exit(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
#! /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 |
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
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*)(!?)$/ |
OlderNewer