Skip to content

Instantly share code, notes, and snippets.

@knowlet
knowlet / sic_hw2
Created April 13, 2015 16:43
sic/xe object code
Line Loc Source statement Object code
5 1000 ADDITION START 1000
. I can't find RTL on textbook, is it STL?
10 1000 FIRST STL RETADR 172020
15 1003 BASE ALPHA
20 1003 LDB #ALPHA 690000
25 1006 LDS #3 6D0000
30 1009 LDT SIZE 77201A
35 100C LDX #0 050000
40 100F ADDLP LDA ALPHA,X 03A012
@knowlet
knowlet / showNumNoRepeat.c
Created May 27, 2015 05:08
Write a C program which reads an integer number n and produces all n-digit numbers with no repeated digits.
#include <stdio.h>
#include <stdlib.h>
int increase(char* a, int n);
int checkRepeat(char* a, int n)
{
int i, j;
for (i = 0; i < n-1; ++i)
// 檢查數字中是否有重複出現的數字
@knowlet
knowlet / MasterMind.cpp
Last active August 29, 2015 14:22
A sample mastermind game demo.
#include <iostream>
#include <string>
using namespace std;
void MasterMind(string master, string mind, int* b, int* w)
{
bool* checked1 = new bool[master.length()];
bool* checked2 = new bool[master.length()];
memset(checked1, false, master.length());
memset(checked2, false, master.length());
@knowlet
knowlet / intOverflow.c
Created July 5, 2015 13:40
A sample int overflow crackme.
#include <stdio.h>
#include <stdlib.h>
#define KEYMAXLEN 64
void printKey(int c)
{
char bits[4];
char *buffer;
int i = 0;
while (c != -1) {
@knowlet
knowlet / auto99.user.js
Created August 26, 2015 13:21
auto pagging for 99comic
// ==UserScript==
// @name auto99
// @namespace http://knowlet.me/
// @version 0.1
// @description auto pagging for 99comic
// @author knowlet
// @match http://www.99comic.com/comics/*
// @grant none
// ==/UserScript==
var a = document.querySelector(".cHeadNav")
#!/bin/bash
USER=knowlet
git remote add -f $1 https://github.com/$USER/$1.git
git merge -s ours --no-commit $1/master
git read-tree --prefix=$1/ -u $1/master
git commit -m "Subtree merged in $1"
@knowlet
knowlet / slides.js
Created September 17, 2015 14:12
put ypur own image url into slides!
$(".sl-block-content").click(function (e){
if (this.innerHTML=="") {
var URL = prompt("Please input the image src")
URL && $(this).append('<img src="' + URL + '">')
}
})
@knowlet
knowlet / dm5.js
Created January 3, 2016 15:37
Automatic load comic pictures.
var table = document.querySelector("table");
var source = document.querySelector("td[align] img").src.slice(0, -7);
var pages = Number(location.pathname.slice(-11, -8));
for (var i = 2; i <= pages; ++i) {
var row = table.insertRow(i+3);
row.align="center";
var cell = row.insertCell(0);
var page = ("000"+i).substr(-3);
cell.innerHTML = '<img src="' + source + page + '.jpg" border="0" onload="if(this.width>screen.width) {this.resized=true; this.width=screen.width*0.96;}">';
}
@knowlet
knowlet / plurk.css
Last active February 18, 2016 16:13
My Plurk custom CSS
/* 河道上的噗 */
.plurk_cnt {
/* 設定噗跟預設一樣大小的圓角 */
border-radius: 0 0 10px 10px;
/* 調整成跟展開一樣寬 */
min-width: 380px;
}
.response_time.plurk_cnt {
/* 110 + 10 + 2 */
min-width: 122px;
@knowlet
knowlet / vhost.conf
Created February 25, 2016 17:18
Easy config file to use folder as subdomain, just put it in /etc/nginx/conf.d/
server {
listen 80;
root /var/www/html/$subdomain;
index index.php index.html index.htm;
server_name ~^(?<subdomain>.+).knowlet.me$;
location / {
try_files $uri $uri/ =404;