Skip to content

Instantly share code, notes, and snippets.

View aldente39's full-sized avatar
🍂

aldente39 aldente39

🍂
View GitHub Profile
@aldente39
aldente39 / sump.py
Created December 20, 2011 00:05
The sum of prime progression (Parallel)
from multiprocessing import Pool
import time
def isPrime(n):
if n < 2:
return 0
if n == 2:
return n
if n % 2 == 0:
return 0
@aldente39
aldente39 / roman.py
Created January 4, 2012 11:21
roman_numerals
def main():
while True:
n = input()
if 0 < n < 10000:
break
print 'Error: input 1 ~ 9999'
s = str(n)
c = ''
try:
@aldente39
aldente39 / .vimrc
Created January 7, 2012 10:27
To compile & run by F5 (Vim)
"実行コマンド
command! Run call s:Run()
nmap <F5> :Run<CR>
function! s:Run()
let e = expand("%:e")
if e == "c"
:Gcc
endif
if e == "py"
:Python
import random
#import pylab
import copy
G = 1.0
H = 3.5
M = 1.0
def ngp(data, n):
m = [[0] * (n+1) for i in range(n+1)]
@aldente39
aldente39 / timeit.c
Created January 29, 2012 09:51
timeit command
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<windows.h>
int main(int argc, char *argv[]){
clock_t start, end;
FILETIME creationTime, exitTime;
@aldente39
aldente39 / quicksort.py
Created February 20, 2012 09:30
quicksort
import random
import sys
import time
def quicksort(a, left, right):
if left < right:
p = left
k = left + 1
while k <= right:
if a[k] < a[left]:
@aldente39
aldente39 / randomized_auicksort.py
Created February 20, 2012 09:32
randomized quicksort
import random
import time
def randomized_quicksort(a, left, right):
if left < right:
r = random.randint(left, right)
a[r], a[left] = a[left], a[r]
p = left
k = left + 1
while k <= right:
@aldente39
aldente39 / tk_animation_test.py
Created February 26, 2012 02:50
tk_animation_test
import Tkinter as tk
import time
root = tk.Tk()
c0 = tk.Canvas(root, width = 300, height = 300)
for i in range(0,202,2):
time.sleep(0.1)
n = c0.create_oval(i,125,50+i,175, tags = 'o')
c0.pack()
c0.update()
@aldente39
aldente39 / myls.ps1
Created March 22, 2012 15:18
ls with color
#rm alias:ls -force
#set-alias ls myls
filter lsColor{
if($_.mode[0] -eq "d"){
Write-Host $_.name -ForeGroundColor Green
}
elseif($_.get_Extension() -eq ".exe"){
Write-Host $_.name -ForeGroundColor Yellow
}
function AddPath([string]$x){
$p = pwd
$name = "Path"
sl HKCU:
$s = Get-ItemProperty "HKCU:Environment" $name
sl $p
$s = $s.$name
Write-Host "path length:" $s.length + $x.length
if(($s.length -eq 0) -or ($s[-1] -eq ";")){
$s += $x