Skip to content

Instantly share code, notes, and snippets.

@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) ))
@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 / 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 / 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 / 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 / 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 / urldecode
Last active July 15, 2022 22:35
URL unencodes (decodes) a string passed via command line
#!/usr/bin/env python
import sys, urllib
if __name__ == '__main__':
args = sys.argv[1:]
for arg in args:
print urllib.unquote( arg )
@antun
antun / testRut.js
Created April 7, 2021 16:31
Chile RUT Validation
var ruts = [
'12.678.579-8', // Valid - with extra digits
'76086428-5', // Valid
'220604497', // Valid no dash
'12531909-2', // Valid
'76.498.451-K', // Valid - with K verification number
'76086428', // Invalid missing verificationNumber
'12.678.579-7', // Invalid verificationNumber
'76.498.451-0', // Invalid verificationNumber
@antun
antun / index.html
Created August 21, 2019 20:39
Minimal Configure - YCC
<header class="site-header">
<!-- adding a dummy header like most sites will already have -->
<h1 class="header-title">Configure 3.134.1 <span class="configure-reference-type">YCC Test Page</span></h1>
<div class="demo-links" style="display:none">
<a href="../">other demos</a>
<a href="#">source</a>
<a href="#">download</a>
<a href="#">edit</a>
@antun
antun / jsonp2json
Last active December 20, 2018 18:58
#!/usr/bin/env python
import sys
rawinput = sys.stdin.read()
output = rawinput[ rawinput.index("(") + 1 : rawinput.rindex(")") ]
print(output)