This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: 0: exit normally | |
:: others: failed | |
a.exe 0 | |
if not %ERRORLEVEL% == 0 goto __FAILED | |
echo succeeded. | |
goto __EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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 & _ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; -*- Mode: Lisp; Package: editor -*- | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; .xyzzy ;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |