Skip to content

Instantly share code, notes, and snippets.

⚡️
Hello World!

Hi girvan

⚡️
Hello World!
  • US
Block or report user

Report or block girvan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@girvan
girvan / lite__init__.py
Created Aug 28, 2011
你覺的第18行這樣子寫如何?
View lite__init__.py
import sys
import types
import os
import urllib
import cgi
import logging
from Cookie import SimpleCookie
# instance
_liter = None
@girvan
girvan / main.py
Created Sep 10, 2011
hello world demo by using pili.lite
View main.py
from pili import lite
def main():
lite.init(globals())
echo('hello world')
if __name__ == '__main__':
main()
@girvan
girvan / gist:1390751
Created Nov 24, 2011
Javascript bookmark for scrolling test
View gist:1390751
javascript:(function () { var scroll_length = 20; var stuck_threshold = 2; var height = 4000; var url = window.location.href.split("url=")[1]; var wait = parseInt(url.split("#")[1]); var start_time = new Date().getTime() / 1000; var yo = function () { document.getElementById('ttt').contentWindow.document.getElementById('footer-links').innerHTML += "<div style='background-color:gray;width:10px;position:absolute;height:" + height + "px;top:0;left:0;'>&nbsp;<\/div>"; var win = document.getElementById('ttt').contentWindow; var doc = document.getElementById('ttt').contentWindow.document; var i = 0; var last = 0; while (i < height) { win.scrollTo(0, i); i += scroll_length; } alert("#take:" + ((new Date().getTime() / 1000) - start_time - wait / 1000)); }; setTimeout(yo, wait); document.body.innerHTML = ("<iframe id='ttt' src='" + url + "' width='100%' height='100%'></iframe>"); })();
@girvan
girvan / gist:2155315
Created Mar 22, 2012
把下面這一段貼到bashrc裡面即可
View gist:2155315
function wtitle(){ echo -ne "\033]0; $@ \007"; }
@girvan
girvan / fetch-content-by-using-gae.py
Created Mar 22, 2012
到shell.appspot.com,然後執行下列指令即可
View fetch-content-by-using-gae.py
from google.appengine.api import urlfetch
result = urlfetch.fetch("http://software.sopili.net/")
result.content
View htmlhex_decode.php
function htmlhex_decode($str){
if(preg_match_all("/&#(\d+);/",$str,$match)){
foreach($match[1] as $key=>$value){
$str=str_replace($match[0][$key],"\u".dechex($value),$str);
}
}
$str=preg_replace("/&#x(\d+);/","\\u$1",$str);
$str=str_replace(Array("\r","\n"),Array("\\r","\\n"),$str);
View big52utf8.php
function big52utf8($big5str) {
$blen = strlen($big5str);
$utf8str = "";
for($i=0; $i<$blen; $i++) {
$sbit = ord(substr($big5str, $i, 1));
//echo $sbit;
//echo "<br>";
if ($sbit < 129) {
View init.php
//一開始總是必要的
require '/home/www/config.php';
//或是這樣
require '../config.php'; //但這樣子在crontab不能跑
//當然,接下來的路徑就使用變數或常數來寫程式
require SOPILI_PATH.'/lib/db_connection.php';
View init.php
<?php
require '../../config.php'; //原本是這樣
require dirname(__FILE__)."/../../config.php"; //改成這樣
View gist:2155403
<?php
//宣告
var url_arr=new Array('software.sopili.net','dev.sopili.net');
//讀取
for(var i in url_arr){
document.write(url_arr[i]+'<br>');
}
You can’t perform that action at this time.