Skip to content

Instantly share code, notes, and snippets.

View girvan's full-sized avatar
Hello World!

Hi girvan

Hello World!
View GitHub Profile
<meta name="viewport" id="viewport" />
<script>
var viewport_width = 400;
(function(target_width){
var device_width = screen.width || 320,
ratio = (device_width/target_width);
// desktop or some old mobile browser
if(device_width > 414 || device_width < 320)
ratio = 1.0;
document.getElementById('viewport').content = "width=device-width,user-scalable=1,initial-scale=" + ratio;
(function(w, ua){
if(ua.indexOf('Android') > -1 && ua.indexOf('Chrome') ==-1)
return;
$("body").css('min-height', Math.ceil(
$(document).width() * ($(w).height()/$(w).width())
));
})(window, navigator.userAgent);
tinypng() {
for f in *.png
do
cmd="curl -s --user api:YOUR_API_KEY --data-binary @$f https://api.tinypng.com/shrink | sed 's/.*https/https/g' | sed 's/\.png.*/.png/g' | xargs curl -s -o $f"
eval "$cmd";
done
}
@girvan
girvan / php-fpm-cli
Last active August 29, 2015 14:16 — forked from muhqu/php-fpm-cli
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Mathias Leppich <mleppich@muhqu.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
root /home/wwwroot;
+ error_page 500 502 503 504 /static/500.html;
<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<style type="text/css">
#main { font-family: arial; font-size:18px; }
#time { position:fixed; bottom:5px; right:5px; color:lightgray;}
</style>
<body>
<span id="time"></span>
<span id="main">Loading<span id="dot">.</span></span>
@girvan
girvan / preload.inc.php
Last active August 29, 2015 14:26
dbchecker file
<?php
if(is_file('/home/wwwroot/dbchecker'))
require LIB_PATH . '/database/checker.php';
<?php
$mysql_checker = function(){
$cfg = explode("\t", DB_CFG);
error_reporting(E_ERROR);
$try_num = 20;
$try_interval = 500000; // 0.5 sec
foreach(range(0, $try_num) as $times)
{
@girvan
girvan / lite__init__.py
Created August 28, 2011 06:57
你覺的第18行這樣子寫如何?
import sys
import types
import os
import urllib
import cgi
import logging
from Cookie import SimpleCookie
# instance
_liter = None
@girvan
girvan / main.py
Created September 10, 2011 03:14
hello world demo by using pili.lite
from pili import lite
def main():
lite.init(globals())
echo('hello world')
if __name__ == '__main__':
main()