Skip to content

Instantly share code, notes, and snippets.

View girvan's full-sized avatar
Hello World!

Hi girvan

Hello World!
View GitHub Profile
@girvan
girvan / gist:1390751
Created November 24, 2011 06:22
Javascript bookmark for scrolling test
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>"); })();
<?php
//宣告
var url_arr=new Array('software.sopili.net','dev.sopili.net');
//讀取
for(var i in url_arr){
document.write(url_arr[i]+'<br>');
}
<?php
$counter_file='count.txt';
$count=intval(file_get_contents($counter_file));
$handle=fopen($counter_file,'w+');
fwrite($handle,$count+1);
fclose($handle);
<?php
$HTTP["host"] == "event.sopili.com" {
server.document-root = "/home/www/event/"
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/local/bin/php-cgi -c /usr/local/etc/php_event.ini",
"socket" => "/tmp/event-php-fastcgi.socket",
))
)
<label><input name='func' type='radio' value='abc' />abc</label>
....
<script type='text/javascript'>
jQuery(document).ready(function(){
jQuery("input[name=func][value='abc']").attr('checked',true);
});
</script>
<?php
if(empty($_SESSION['id'])) //必需要先登入
die('Please Login First');
must_referer("http://admin.tools.sopili.net"); //來源一定要是從 admin.tools.sopili.net 操作
save_post($_POST['content'],$_SESSION['id']); //可以進行儲存的動作
/<div>[\n\r.]*?<\/div>/ig
<select name='list'>
<option value=''>all</option>
<option value='abc'>abc</option>
</select>
<script type='text/javascript'>
jQuery(document).ready(function(){
jQuery("select[name=list]").val("abc");
});
</script>
<?php
if(empty($_SESSION['id'])) //必需要先登入
die('Please Login First');
save_post($_POST['content'],$_SESSION['id']); //可以進行儲存的動作
<?php
//input可以是單一字串,或是array
function must_referer($src){
$src_arr=Array();
if(empty($_SERVER['HTTP_REFERER'])) //一定要有referer url
exit;
$src_arr=(is_array($src))?$src:Array($src);
foreach($src_arr as $url)
if(strpos($_SERVER['HTTP_REFERER'],$url)===0) //一定要match到,而且是第一個字元就要match到