Skip to content

Instantly share code, notes, and snippets.

@sunapi386
sunapi386 / 2048botter
Last active August 29, 2015 13:57
2048 bot
// Sometimes solves kortaggio's 5x5 variant of 2048: http://kortaggio.github.io/2048/
// Open the javascript console with F12 and copy past this in.
// export the game manager into the global namespace
GameManager.prototype.__original_actuate = GameManager.prototype.actuate;
GameManager.prototype.actuate = function() {
window.gm = this;
this.__original_actuate();
GameManager.prototype.actuate = GameManager.prototype.__original_actuate;
};
@sunapi386
sunapi386 / mutt
Created March 14, 2014 00:27
marc burns mutt send config
# sending
# SMTP use the univ serv
set smtp_url="smtp://j53sun@mailservices.uwaterloo.ca:587"
set ssl_starttls=yes
set ssl_force_tls=yes
@sunapi386
sunapi386 / gist:8f395711409c9fde93c7
Created June 24, 2014 02:59
Make Rooms in Claims
r = session.query(ClaimRoom)[-1]
for name in range(0,10):
ClaimAsset(room=r,product_type_name=name,simple=False)
session.commit()
@sunapi386
sunapi386 / newgistfile1
Created October 22, 2013 21:18
What does this gist do? Nothing. Just testing and checking what this is.
Apparently, gist is a simple way to share snippets and pastes with others. All gists are Git repositories, so they are automatically versioned, forkable and usable from Git.
Output the symmetric difference of two sorted streams of numbers.
Examples:
list1 = [1,3,5,8]
list2 = [2,5,6,7,8]
output = [1,2,3,6,7]
input1 = [1,2,3,4,99,100]
input2 = [3,4,5,6,99]
output = [1, 2, 5, 6, 100]
@sunapi386
sunapi386 / qq_fetcher.js
Created March 19, 2016 07:05
Fetches blog from qqzone
// http://user.qzone.qq.com/765591203
var pages = document.getElementById("tblog").contentWindow.document.getElementsByClassName("mod_pagenav_count")[0];
var posts = document.getElementById("tblog").contentWindow.document.getElementById("listArea").getElementsByTagName("li");
for (var i = 0; i < 1 /*posts.length*/; i++) {
var postTitle = posts[i].getElementsByClassName("article")[0].textContent;
var postLink = posts[i].getElementsByClassName("article")[0].getElementsByTagName("a")[0].href
// http://user.qzone.qq.com/765591203/blog/1400775512
var entryDate = posts[i].getElementsByClassName("list_op")[0].childNodes[0].textContent;
var readCount = posts[i].getElementsByClassName("list_op")[0].childNodes[2].textContent;
<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
function submit()
{
wsUri = document.getElementById("wsUriInput").value;
testWebSocket();
// #bodyContent > div.mw-content-ltr > table:nth-child(21) > tbody > tr:nth-child(500)
//*[@id="bodyContent"]/div[4]/table[10]/tbody/tr[500]
// bgcolor="33CC33"
c=document.getElementById("bodyContent")
d=c.getElementsByClassName("mw-content-ltr")[0]
e=d.getElementsByTagName("table")
phoneTable=e[e.length - 4]
phoneBuilds = []
@sunapi386
sunapi386 / duplicates.rb
Created January 30, 2017 22:39
Ruby script for checking duplicate file names
## Jason Sun <jason@sunapi386.ca>
## Jan 30, 2017
##
## Lists the duplicate files in the two given directories.
## Simple, only compares names. Case sensitive.
## Options:
## - filter by file extension
## - list the non-duplicate files
## - show the list (vs just stats)
@sunapi386
sunapi386 / comments.sh
Created February 9, 2017 03:08
train stats
bash-3.2$ find . \( -iname "*.h" -o -iname "*.c" \) -exec /bin/echo {} + | xargs awk -f lc.awk
--------------------------------File---Code---Comments---Raw Lines
-------------- ./include/kernel/scheduler.h 68 11 93
./user/sensor.c 154 25 190
./track/new/track_data_new.c 2352 1 2357
./include/user/clock_drawer.h 4 0 6
./include/utils.h 36 0 46
./include/user/parser.h 5 0 6