Skip to content

Instantly share code, notes, and snippets.

View soimort's full-sized avatar

Mort Yao soimort

View GitHub Profile

Keybase proof

I hereby claim:

  • I am soimort on github.
  • I am soimort (https://keybase.io/soimort) on keybase.
  • I have a public key whose fingerprint is 8A9C A653 83B6 71BC 995C CEAE 07DA 00CB 7820 3251

To claim this, I am signing this object:

@soimort
soimort / gist:6f5e75050ee7fbb7c117
Created March 23, 2015 03:33
Compiling CppSharp on Linux
➜ build git:(master) make -C gmake config=release_x64
make: Entering directory `/home/soimort/Source/CppSharp/build/gmake'
==== Building CppSharp.AST (release_x64) ====
Creating ../lib/Release_x64
Creating ../obj/x64/Release/CppSharp.AST
==== Building CppSharp.Runtime (release_x64) ====
Creating ../obj/x64/Release/CppSharp.Runtime
==== Building CppSharp.CppParser (release_x64) ====
Creating ../obj/x64/Release/CppSharp.CppParser
AST.cpp
@soimort
soimort / kalendar
Created September 14, 2011 13:39
HKR kursschema ics converter
<?php
$file = file_get_contents($_GET['URL'], "r") or die("Error. File not found");
$lower = html_entity_decode(strstr($file, "</tr><tr"), ENT_QUOTES);
$line = (explode("</tr>", $lower));
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:PHP\n";
@soimort
soimort / main.c
Created December 1, 2011 15:42
ECB-DES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void exor4(char *destination, const char *source1, const char *source2)
{
*destination &= 0x0F;
for (int i = 0; i < 4; i++)
*destination |= (((*source1 >> (7 - i)) & 1) ^ ((*source2 >> (7 - i)) & 1)) << (7 - i);
@soimort
soimort / pe001.py
Created March 5, 2012 00:47
Project Euler - Problem 1
print(3 * (999 // 3 + 1) * (999 // 3) // 2
+ 5 * (999 // 5 + 1) * (999 // 5) // 2
- 15 * (999 // 15 + 1) * (999 // 15) // 2)
@soimort
soimort / pe002.py
Created March 5, 2012 00:52
Project Euler - Problem 2
a, b, i, sum = 1, 2, 2, 0
while b <= 4000000:
if b % 2 == 0:
sum += b
a, b, i = b, a + b, i + 1
print(sum)
@soimort
soimort / pe003.py
Created March 5, 2012 00:54
Project Euler - Problem 3
n = 600851475143
while n % 2 == 0:
n //= 2
i = 1
while n > 1:
i += 2
while n % i == 0:
n //= i
print(i)
@soimort
soimort / pe005.py
Created March 5, 2012 15:47
Project Euler - Problem 5
def gcd(a, b):
if a:
return gcd(b % a, a)
else:
return b
lcm = lambda a, b: a * b // gcd(a, b)
m = 1
for i in range(2, 21):
m = lcm(m, i)
print(m)
@soimort
soimort / pe004.py
Created March 5, 2012 15:44
Project Euler - Problem 4
for n in range(999, 99, -1):
m = int(str(n) + str(n)[::-1])
for i in range(999, 99, -1):
if m % i == 0 and len(str(m // i)) == 3:
print(m)
exit()
@soimort
soimort / pe006.py
Created March 5, 2012 15:47
Project Euler - Problem 6
print(((100 + 1) * 100 // 2) ** 2
- sum([i ** 2 for i in range(1, 101)]))