Skip to content

Instantly share code, notes, and snippets.

@nansenat16
nansenat16 / csv2vcf.php
Created December 23, 2011 10:21
convert outlook express BIG5 csv to RoundCube support vCard file
<?php
//
// http://homepage.mac.com/phrogz/CSV2vCard_v2.html
// http://en.wikipedia.org/wiki/VCard
// Test CentOS 5.7 PHP 5.3.3
// 2011/12/23 by nansen.su
// 2012/02/16 support Thunderbird 10
$field=array(
array('名稱','prefix'),
@nansenat16
nansenat16 / gist:2723353
Created May 18, 2012 05:30
給工程師 – 生命就該浪費在有意義的事上
Source http://brooky.cc/2012/05/18/給工程師-生命就該浪費在有意義的事上
給工程師 – 生命就該浪費在有意義的事上
Posted on May 18, 2012 by brooky
前幾天看了 Mr. jamie 的文章年輕人,勇敢加入「明日」的台積電吧!, 剛好幾前天朋友也轉寄了一篇Life is too short to write shitty software給我,裡面講到
Life’s too short to be creating shitty software.
@nansenat16
nansenat16 / pdf2png.php
Created August 14, 2012 07:01
Use ImageMagick Convert PDF to PNG with 300dpi
<?php
$pdf_dir='./pdf';
$pdf_dir=realpath($pdf_dir);
$imgcov='"C:\Program Files\ImageMagick-6.7.8-Q16\convert.exe" -density 300 "%s" "%s"';
$f=opendir($pdf_dir);
while(($name=readdir($f))!==false){
$file=$pdf_dir.'\\'.$name;
if(!is_dir($file)){
<html>
<head>
<title>Mongodb Status <?php echo date('Y/m/d H:i:s');?></title>
<style type="text/css">
table,td{border:1px solid #000;}
.coll{margin-left:50px;}
</style>
</head>
<body>
<h3>MongoDB Status</h3>
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
s.bind(('0.0.0.0',68))
mymac='\x01\x02\x03\x04\x05\x06' #your MAC Address
magic_cookie='\x63\x82\x53\x63'
pkg='\x01\x01\x06\x00\x11\x22\x33\x44' + ('\x00'*20) + mymac + ('\x00'*202) + magic_cookie
<?php
if(isset($_SERVER['HTTP_USER_AGENT'])){
$l=array('Android','iPhone','iPad');
foreach($l as $item){
if(stripos($_SERVER['HTTP_USER_AGENT'],$item)!==false && !isset($_GET['pda'])){
header('location: ?pda');
exit;
}
}
}
// this script is a local post-update hook script.
// http://tortoisesvn.googlecode.com/svn/trunk/contrib/hook-scripts/client-side/PostUpdate.js.tmpl
var objArgs,num;
objArgs = WScript.Arguments;
num = objArgs.length;
if (num != 5)
{
WScript.Echo("Usage: [CScript | WScript] PostUpdate.js path/to/pathsfile depth revision error path/to/CWD ");
@nansenat16
nansenat16 / auto_rootpw.ks
Created July 14, 2013 10:44
auto generated root password from mac address with installer
# Kickstart file automatically generated by anaconda.
install
text
cdrom
lang en_US.UTF-8
keyboard us
%include /tmp/rootpw
authconfig --enableshadow --passalgo=sha512
@nansenat16
nansenat16 / stop_countback.html
Created July 19, 2013 04:06
示範更換分頁停止倒數
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
var count=0;
$(window).blur(function(){
console.log('out');
$('#msg').data('where','out');
});
@nansenat16
nansenat16 / dns_rec.php
Last active December 29, 2015 10:59
tcpdump sniffer DNS query and log it
<?php
// Usage:
// #tcpdump -i eth1 -n|grep domain|php dns_rec.php
// #nohup tcpdump -i eth1 -n|grep domain|php dns_rec.php &
//
ini_set('memory_limit','256M');
$qmap=array();
define('LOG_PATH','/root/dns_%s.csv');
$f=fopen('php://stdin','r');