Skip to content

Instantly share code, notes, and snippets.

View hidsh's full-sized avatar

yakshaver hidsh

View GitHub Profile
@hidsh
hidsh / test.c
Created January 10, 2012 02:16
return result code
#include <stdio.h>
#include <stdlib.h> /* atoi */
int main(int argc, char *argv[])
{
int ret = -1;
if(argc>1) {
ret = atoi(argv[1]);
printf("%d\n", ret);
@hidsh
hidsh / test-result-code.bat
Created January 10, 2012 02:17
test result code
@echo off
:: 0: exit normally
:: others: failed
a.exe 0
if not %ERRORLEVEL% == 0 goto __FAILED
echo succeeded.
goto __EOF
@hidsh
hidsh / write-buffer-as.l
Created January 19, 2012 08:41
xyzzy: write-buffer /w recursive mkdir
;;
;; write-buffer-as
;;
(provide 'write-buffer-as)
(defun write-buffer-as (new-name)
(interactive "FWrite file as: " :default0 (if (get-buffer-file-name)
(get-buffer-file-name)
(concat (get-special-folder-location :desktop)
@hidsh
hidsh / test.c
Created January 31, 2012 15:11
look up table /w linear interpolation
/*
look up table /w linear interpolation
$ gcc -std=c99 test.c && a.out
$ gnuplot
gnuplot> plot "k.txt" notitle
*/
#include <stdio.h>
#include <stdlib.h>
@hidsh
hidsh / test_filter_lambda.py
Created February 1, 2012 06:27
python: sample of fiter and lambda
def even(x):
return x % 2 == 0
l = range(0, 10)
print filter(even, l)
print filter(lambda x: x % 2, l) # odd()
# result
# [0, 2, 4, 6, 8]
@hidsh
hidsh / bak_rotate.vbs
Created February 6, 2012 07:34
backup file /w rotation
' bak_rotate
nbak_default = 10 'number of backups as default
' -- main procedure
Set args = WScript.Arguments
If args.Count < 1 Or args.Count > 2 Then
error_exit("usage: bak_rotate.vbs filename n" & vbCrLf & _
" bak_rotate.vbs filename" & vbCrLf & _
" e.g. bak_rotate.vbs x.c 3 --> x_0.c x_1.c x_2.c" & vbCrLf & _
@hidsh
hidsh / .xyzzy
Created February 8, 2012 02:02
my .xyzzy
;;; -*- Mode: Lisp; Package: editor -*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; .xyzzy ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@hidsh
hidsh / dict_test.py
Created February 16, 2012 18:00
python dictionary test
class t_path:
def __init__(self, path, externp):
self.path = path
self.externp = externp
d = dict()
# append
d['varx'] = t_path('path/to/srcx.c', True)
d['var1'] = t_path('path/to/src1.c', False)
@hidsh
hidsh / args_basic.py
Created February 21, 2012 00:52
python args test
import sys # args
for a in enumerate(sys.argv):
print ' sys.argv[%d]: \'%s\'' % a
# result
# D:\py>args_basic.py aa bb cc
# sys.argv[0]: 'D:\py\args_basic.py'
# sys.argv[1]: 'aa'
# sys.argv[2]: 'bb'
@hidsh
hidsh / path_name_test.py
Created February 21, 2012 01:32
python path name test
import sys # args
import os.path
path_py_script = sys.argv[0]
print ' sys.argv[0] : "%s"' % path_py_script
print ' os.path.dirname() : "%s"' % os.path.dirname(path_py_script)
print ' os.path.basename() : "%s"' % os.path.basename(path_py_script)
print ' os.path.splitext() : "%s" "%s"' % os.path.splitext(path_py_script)