Skip to content

Instantly share code, notes, and snippets.

View 123jimin's full-sized avatar
🏠
Working from home

Jimin Park 123jimin

🏠
Working from home
View GitHub Profile
@123jimin
123jimin / X.java
Created March 27, 2013 16:21
An example shows that a seed can encode a 6-byte long string.
import java.util.Random;
public class X{
static{
byte[] b = new byte[6];
new Random(0xFE7147F36BBFL).nextBytes(b);
System.out.println(new String(b));
}
}
@123jimin
123jimin / X.java
Created March 27, 2013 16:46
"Hello, world!" in Java
import java.util.Random;
class X {
public static void main(String[] s) {
byte[] a = new byte[6], b = new byte[6];
new Random(0x437950CAAB99L).nextBytes(a);
new Random(0xD6FD03B08D76L).nextBytes(b);
System.out.println(new String(a) + " " + new String(b));
}
}
@123jimin
123jimin / SeedGenerator.java
Created March 28, 2013 09:43
Enter a 6-byte string, then this will emit a Java program printing the string.
import java.util.Random;
import java.util.Scanner;
public class SeedGenerator {
public static void main(String[] args) throws Exception{
Scanner scanner = new Scanner(System.in);
System.out.print("Write a 6-byte string: ");
String string = scanner.next();
byte[] b = string.getBytes("UTF-8");
@123jimin
123jimin / CPUem.cs
Created April 9, 2013 09:23
I spot a serious bug here
case (int)instructions.Div://divides regB with regC and puts the result in regA
if (register[regB] == 0)
return -1;
register[regA] = register[regB] / register[regC];
executionTime += 39;
break;
@123jimin
123jimin / trash.js
Last active December 16, 2015 10:29
I have committed a lot of terrible mistakes involving rm, so I coded this script to prevent any further accidents.
#!/usr/bin/env node
var fs = require('fs');
var help = "Usage : trash [-lhx] files...\n\t-l : list trashcan\n\t-x : cancel (files: timestamp)\n\t-h : help";
var trash = process.env['HOME'] + "/.trash/";
(function(argv, log, error) {
argv = require('optimist').parse(argv);
if (typeof argv.l === 'string') {
@123jimin
123jimin / AutoPoke.js
Created May 14, 2013 15:21
AutoPoke.js
String.prototype.pad = function(i){
var s = this;
while(s.length<i) s="0"+s;
return s;
}
Date.prototype.format = function(s){
s = s.replace(/Y/g,this.getFullYear());
s = s.replace(/M/g,(this.getMonth()+1).toString().pad(2));
s = s.replace(/d/g,this.getDate().toString().pad(2));
@123jimin
123jimin / evalEq.php
Created July 11, 2013 09:07
The parser I made (100% hand-coded) back in 2011.
<?php
require_once('echoErr.php');
require_once('token.php');
require_once('complex.php');
require_once('constant.php');
require_once('function.php');
require_once('evalInfo.php');
mb_internal_encoding('UTF-8');
set_time_limit(5);
/*
0. Go to http://gabrielecirulli.github.io/2048/
1. Copy & Paste below 3 lines to the console.
2. Every time a move is done, a prompt will be opened.
3. Input two integers (separated by a slash), where
the first integer indicates the place where the tile will appear,
and the second integer indicates the type of the tile (2 or 4 only).
The place will be indicated by the index in the list of empty tiles (after the move),
where the first one is leftmost+upmost and the next one is below of the first one.
(For example, if every tiles are empty, then the tiles will have index 0 4 8 12 / 1 5 9 13 / 2 6 10 14 / 3 7 11 15.)
@123jimin
123jimin / forbidden.dump
Created March 27, 2014 03:58
Dump of forbidden char
FORBIDDEN_CHAR | 00 00 00 00 00 00 00 00 58 00 00 00 2F 00 00 00 25 00 29 00 2C 00 2E 00 3A 00 3B 00 3E 00 3F 00 5D 00 5E 00 60 00 7D 00 7E 00 B0 00 B7 00 19 20 1D 20 24 20 25 20 26 20 30 20 31 20 32 20 33 20 34 20 35 20 36 20 37 20 03 21 09 21 01 30 02 30 03 30 05 30 09 30 0B 30 0D 30 0F 30 11 30 15 30 17 30 19 30 1B 30 41 30 43 30 45 30 47 30 49 30 63 30 83 30 85 30 87 30 8E 30 9B 30 9C 30 9D 30 9E 30 A1 30 A3 30 A5 30 A7 30 A9 30 C3 30 E3 30 E5 30 E7 30 EE 30 F5 30 F6 30 FB 30 FC 30 FD 30 FE 30 01 FF 05 FF 09 FF 0C FF 0E FF 1A FF 1B FF 1E FF 1F FF 3D FF 3E FF 40 FF 5D FF 5E FF 65 FF 24 00 3C 00 5B 00 5C 00 7B 00 A2 00 A3 00 A4 00 A5 00 A7 00 F2 09 F3 09 3F 0E 18 20 1C 20 A0 20 A1 20 A2 20 A3 20 A4 20 A5 20 A6 20 A7 20 A8 20 A9 20 AA 20 AB 20 AC 20 08 30 0A 30 0C 30 0E 30 10 30 14 30 16 30 18 30 1A 30 04 FF 08 FF 1C FF 3B FF 3C FF 5B FF E0 FF E1 FF E5 FF E6 FF
<FORBIDDEN Id="0">IAA=</FORBIDDEN>
<FORBIDDEN Id="1">IAA=</FORBIDDEN>
<FORBIDDEN Id="2">JQApACwALgA6ADsAPgA/AF0AXgBgAH0AfgCwALcAGSAdICQgJSAmIDAgMSAy
@123jimin
123jimin / war.ll
Created April 13, 2014 02:45
Google Codejam Qualification Round 2014 / War
%char = type i8
%int = type i32
@casef = internal constant [17 x %char] c"Case #%d: %d %d\0A\00"
@finf = internal constant [3 x %char] c"%f\00"
@dinf = internal constant [3 x %char] c"%d\00"
@doutf = internal constant [4 x %char] c"%d\0A\00"
@foutf = internal constant [4 x %char] c"%f\0A\00"
declare %int @printf(%char* noalias nocapture, ...)