Skip to content

Instantly share code, notes, and snippets.

@antun
antun / urlencode
Last active July 15, 2022 22:36
URL encodes a string passed via the command line.
#!/usr/bin/env python
import sys, urllib
if __name__ == '__main__':
args = sys.argv[1:]
for arg in args:
print urllib.quote( arg )
@antun
antun / xmlunescape
Last active July 15, 2022 22:40
XML unescapes a string
#!/usr/bin/env python
import sys, xml.sax.saxutils
if __name__ == '__main__':
args = sys.argv[1:]
for arg in args:
print xml.sax.saxutils.unescape( arg )
@antun
antun / xmlescape
Last active July 15, 2022 22:41
XML-encodes a string
#!/usr/bin/env python
import sys, xml.sax.saxutils
if __name__ == '__main__':
args = sys.argv[1:]
for arg in args:
print xml.sax.saxutils.escape( arg )
@antun
antun / stopwatch.ino
Created September 12, 2022 17:25
Sunfounder AD Ultrasonic Kit Lesson 13 Stopwatch
/*
* 秒计时器
* 使用定时器1定时0.1秒溢出,设置计数值count,每0.1秒加1,再设置变量n,当
* count加到10,即1秒,n加1,也即n便是n秒
* 计时到10000秒归零
*/
#include <TimerOne.h>
int a = 2;
int b = 3;
@antun
antun / gist:50d140a8ddb0ce05ba6c79e211c15607
Created November 14, 2023 19:27
tictactoe_combinations.js
/*
* Write a program that plays every possible tic-tac-toe game, and then prints the number of valid, completed games
*/
var gameCount = 0;
var board = [null, null, null, null, null, null, null, null, null];
var player0Pointer = 0;
@antun
antun / lctime
Last active January 9, 2024 22:08
Converts time from seconds since 1970 to a human readable date
#!/usr/bin/env python
import sys, time
if __name__ == '__main__':
args = sys.argv[1:]
for arg in args:
print(time.ctime( int(arg) ))