Skip to content

Instantly share code, notes, and snippets.

View MtShadow's full-sized avatar

Mt.Shadow MtShadow

View GitHub Profile
@MtShadow
MtShadow / db.sql
Created June 9, 2016 12:22
db.sql
CREATE TABLE Items (Name text, Price integer, Stock integer, JAN text);
CREATE TABLE Users (Name text, StudentId text, Balance integer);
CREATE TABLE Transactions (ItemId integer, UserId integer, Price integer, MadeAt integer, foreign key(ItemId) references Items(ROWID), foreign key(UserId) references Users(ROWID));
#include "gba.h"
typedef struct __attribute__((packed)) {
hword data[ 16 ]; // Sprite graphic data
} character16;
character16 characters[] =
{
{
{
from __future__ import print_function
import nfc
import sys
def connected(tag):
servc = 0x100B
service_code = [nfc.tag.tt3.ServiceCode(
servc >> 6, servc & 0x3f
)]
@MtShadow
MtShadow / hamming_distance.c
Created May 13, 2016 19:05
MySQL hamming_distance
#include <string.h>
#include <mysql.h>
my_bool hamming_distance_init(initid, args, message)
UDF_INIT *initid;
UDF_ARGS *args;
char *message;
{
if (args->arg_count != 2) {
strcpy( message, "Wrong number of arguments to HAMMING_DISTANCE; accepts exactly two arguments." );
@MtShadow
MtShadow / idcard.py
Created May 7, 2016 11:35
nfcpyを使って筑波大学の学生証から情報を引き抜く
import nfc
servc = 0x100B
def connected(tag):
service_code = [nfc.tag.tt3.ServiceCode(servc >> 6, servc & 0x3f)]
bc_id = [nfc.tag.tt3.BlockCode(i) for i in range(3)]
bc_name = [nfc.tag.tt3.BlockCode(3)]
print tag.read_without_encryption(service_code, bc_id) # 学籍番号を含むID
print tag.read_without_encryption(service_code, bc_name).decode('shift-jis') # 半角カナの名前