Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Jigsaw puzzle</title>
<script type="text/javascript">
function save(filename, data)
{
var blob = new Blob([data], {type: "text/csv"});
@yi
yi / gist:01e3ab762838d567e65d
Created July 24, 2014 18:52
lua hex <= => string
function string.fromhex(str)
return (str:gsub('..', function (cc)
return string.char(tonumber(cc, 16))
end))
end
function string.tohex(str)
return (str:gsub('.', function (c)
return string.format('%02X', string.byte(c))
end))
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active February 19, 2024 21:55
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@uhziel
uhziel / AngleToValid.c
Created September 6, 2012 08:23
将任意角度转化到 [0度,360度)。
float AngleToValid( float fAngle )
{
return fAngle - (int)floorf(fAngle / 360.0f) * 360;
}
@uhziel
uhziel / unameh.sh
Created September 6, 2012 05:08
human version of uname
unameh()
{
echo "kernel-name: $(uname --kernel-name)"
echo "nodename: $(uname --nodename)"
echo "kernel-release: $(uname --kernel-release)"
echo "kernel-version: $(uname --kernel-version)"
echo "machine: $(uname --machine)"
echo "processor: $(uname --processor)"
echo "hardware-platform: $(uname --hardware-platform)"
echo "operating-system: $(uname --operating-system)"
@uhziel
uhziel / run_PAGENT.bat
Created April 23, 2012 02:23
run PAGENT.exe and autoload all .ppk file in the current directory.
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
CALL:wi_run_pageant
GOTO:EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 工具函数
:::::::::::::::::::::::::::::::::::::::::::::::::::::
@uhziel
uhziel / output_all_colours.sh
Created April 22, 2012 13:01
a script that output all the colours to the screen. via http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
#include<time.h>
#include<stdio.h>
int main(void)
{
clock_t ticks1, ticks2;
ticks1=clock();
ticks2=ticks1;
while((ticks2-ticks1)/CLOCKS_PER_SEC<1) {
@uhziel
uhziel / time_t2calendartime.lua
Created March 26, 2012 03:47
convert time_t to calendar time in Lua
function time_t2calendartime(time)
return os.date("%Y-%m-%d %H:%M:%S", time)
end