Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / but.sh
Created March 27, 2015 04:39
big5 to utf8
#!/usr/bin/env bash
for i in `find . -name "*.java"`
do
iconv -f BIG5 -t UTF-8 $i > $i.bak
mv "$i.bak" $i
done
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
@knowlet
knowlet / time.html
Last active August 29, 2015 14:13
What colour is counting down?
<!DOCTYPE html><html><head><title>What colour is counting down?</title><meta charset="UTF-8" ><link href='http://fonts.googleapis.com/css?family=Open+Sans:800,400,300' rel='stylesheet' type='text/css'>
<style>
@media all and (max-width: 1024px) {
h1 { font-family:"open sans"; font-size:40px; font-weight:300; color:white; transition:all 0.6s; -webkit-transition:all 0.6s;}
h2 { font-family:"open sans"; font-size:20px; font-weight:300; color:white; transition:all 0.6s; -webkit-transition:all 0.6s;}
}
@knowlet
knowlet / poe-1-100級快速攻略.vbs
Last active August 29, 2015 14:13
A decrypted vbs file from poe-1-100級快速攻略.vbe
set fso=createobject("scripting.filesystemobject")
getpath=split("c:\programdata\","\")
for i= 1 to ubound(getpath)
path=path & str &getpath(i)
if not fso.folderexists(getpath(0)& str &path)then
fso.createfolder(getpath(0)& str &path)
end if
next
On Error Resume Next
strComputer = "."
@knowlet
knowlet / hello.asm
Last active December 3, 2021 05:13
An assembly template
INCLUDE Irvine32.inc
.data
buffer BYTE "Hello ASM!", 0
.code
main PROC
mov edx, OFFSET buffer
call WriteString
call Crlf
call WaitMsg
#include <stdio.h>
#define a scanf
#define aaa printf
#define aaaaa for
#define aaaaaaa while
#define aaaaaaaaa if
#define aaaaaaaaaaa else
#define aaaaaaaaaaaaa 100
#define aaaaaaaaaaaaaaa 0
#define aaaaaaaaaaaaaaaaa 1
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define jmp(frm,to) (((int)to - (int)frm)-5)
int MemWrite(LPVOID pxAddress,PBYTE code,int size)
{
unsigned long Protection, Ret;
VirtualProtect((LPVOID)pxAddress,size,PAGE_READWRITE,&Protection);
Ret = memcpy((LPVOID)pxAddress,(const LPVOID )code,size);