Skip to content

Instantly share code, notes, and snippets.

View Ronmi's full-sized avatar

Ronmi Ren Ronmi

View GitHub Profile
@Ronmi
Ronmi / DNSQuery.php
Created December 3, 2014 01:30
Pure php code to query DNS record
<?php
/**
* Usage:
* $obj = new DNSQuery('www.google.com', '8.8.8.8', 1, 'A', 'IN');
* if ($obj->isSuccess()) var_dump(DNSQuery::parse($obj->response));
*/
class DNSQuery
{
private $name;
@Ronmi
Ronmi / array_slice_test.vala
Created June 5, 2014 02:39
Vala array slicing test
class Test : Object {
public static int main (string[] args) {
int[] r = {1,2,3,4,5};
stdout.printf ("original: %d %d\n", r[1], r[2]);
int[] a = r[1:2];
a[0] = a[1] = 9;
stdout.printf ("default : %d %d\n", r[1], r[2]);
unowned int[] b = r[1:2];
@Ronmi
Ronmi / gist:385c9c37feccf913cd77
Last active August 29, 2015 14:01
某 SQL Builder 將使用的 FROM 建立語法
<?php
// (`model1` LEFT JOIN `model2` ON `model2`.`col2`=`model1`.`id`)
$from = $b->tables(
$b->left_join($m1, $m2, $b->eq($m2->col2, $m1->id))
);
// `model1`,`model2`,`model3`
$from = $b->tables($m1, $m2, $m3);
@Ronmi
Ronmi / gist:db71bb3ba8c0265017fa
Last active August 29, 2015 14:01
某 SQL Builder 將使用的 WHERE 建立語法
<?php
$where = $b->o( // OR
$b->o(
$b->eq($m2->col2, 1),
$b->a( //AND
$b->ne($m1->id, 2),
$b->lt($m1->id, $b->raw('3*', $m2->id, '-10'))
)
),
$b->not($b->like($m2->col1, 'abc')),
@Ronmi
Ronmi / .fency_bashrc
Created April 7, 2011 02:23
colorful bash prompt with vcs info
function _ps1_git(){
local ref cnt branch clean
ref=$(git symbolic-ref HEAD 2> /dev/null)
cnt=$(git branch 2> /dev/null|grep -c -E '*')
branch=$(echo "${ref#refs/heads/}")
if [[ "${branch}" == "" ]]
then
return
fi
(defun plurk_sorryla ()
"Project sorryla from BobChao"
(interactive)
(insert "對不起,都是我的錯! http://bit.ly/sorryla"))
(defun plurk_c9s ()
"入師直奸"
(interactive)
(insert "人 @c9s 真好 (worship)"))
(global-set-key "\C-cps" 'plurk_sorryla)
deb http://ftp.debian.org/debian lenny main contrib non-free
deb http://ftp.debian.org/debian squeeze main contrib non-free
#!/bin/bash
input=$(xinput list |grep 'SynPS/2 Synaptics TouchPad'|sed -E 's;.*id=([0-9]+).*;\1;'|head -n 1)
xinput set-button-map "${input}" 1 2 3 17 18 19 20 8 9 10 11 12 13 14 15 16
exec xbindkeys
ERROR:dbus.service:Unable to append ({u'source': 2877035514, u'message': u'\u5f9e0.2\u4ee5\u4f86wallbox\u90fd\u4e00\u76f4\u6253\u4e0d\u958b...', u'uid': 1377620908, u'status_id': 406159419125},) to message with signature a{sv}: <type 'exceptions.OverflowError'>: Value -1417931782 out of range for Int32
Traceback (most recent call last):
File "/usr/bin/wallbox-applet", line 8, in <module>
wallbox.run_wallbox ()
File "/usr/lib/pymodules/python2.6/wallbox/wallbox.py", line 219, in run_wallbox
w = wallbox ()
File "/usr/lib/pymodules/python2.6/wallbox/wallbox.py", line 56, in __init__
self.make_ui ()
File "/usr/lib/pymodules/python2.6/wallbox/wallbox.py", line 96, in make_ui
self.notification = notification.Notification ()
diff --git a/configure.ac b/configure.ac
index f943c3c..a179e41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,7 +60,7 @@ AC_SUBST(desktopentrydir)
AS_AC_EXPAND(DATADIR, $datarootdir)
AC_SUBST(DATADIR)
-AS_AC_EXPAND(PYEXECDIR, $pyexecdir)
+AS_AC_EXPAND(PYEXECDIR, $pkgpythondir)