Skip to content

Instantly share code, notes, and snippets.

View nyanshell's full-sized avatar
🐈

Gestalt LUR nyanshell

🐈
View GitHub Profile
@nyanshell
nyanshell / compare.py
Created March 17, 2014 08:49
A test: using google sparse hash in python script
dict()
for i in range(0, 10000000):
d[str(i)] = i + 1
@nyanshell
nyanshell / timus_1022.py
Created March 23, 2014 14:08
simple topological sort
#!/usr/bin/python3
"""
TIMUS 1022
ACCEPTED
2014-03-23
"""
q = set()
n = int(input())
@nyanshell
nyanshell / .emacs
Created March 25, 2014 17:14
emacs configure home
;;load path
(add-to-list 'load-path "/home/gestapolur/.emacs.d/lisp/")
;;tree view
(autoload 'dirtree "dirtree" "Add directory to tree view" t)
(require 'dirtree)
(require 'tree-mode)
(require 'windata)
(require 'twittering-mode)
(custom-set-variables
@nyanshell
nyanshell / id3.py
Last active December 17, 2017 15:42
A Naive Decision Tree Practice, only for discrete values (ID3 algorithm)
# -*- coding: utf-8 -*--
"""
A Naive Decision Tree Practice, Only for discrete values
ID3 algorithm
"""
import math
import copy
from collections import defaultdict
@nyanshell
nyanshell / timus_1008.py
Created April 8, 2014 16:43
timus_1008.py
#!/usr/bin/python2.7
"""
TIMUS 1008
ACCEPTED
2014-04-09
"""
# init
@nyanshell
nyanshell / crypt.sh
Last active August 29, 2015 14:04
a simple script to save password in truecrypt container
#!/bin/bash
# a simple script to save password in truecrypt container
passwd_key= passwd_value= passwd_pair_str=
while [ $# -gt 0 ]
do
case $1 in
-i) passwd_key=$2
passwd_value=$3
@nyanshell
nyanshell / update_motd.service
Created August 3, 2014 11:39
archlinux update /etc/motd with systemd
[Unit]
Description=Update motd
After=sshdgenkeys.service
[Service]
ExecStart=
ExecStart=/usr/bin/update_motd.sh
Restart=always
[Install]
@nyanshell
nyanshell / convert.py
Created October 18, 2014 08:32
Convert xlsx to csv in a directory
#!/bin/python3
# -*- coding: utf-8 -*-
"""
xlsx2csv may have some issues while converting datetime
"""
import xlsx2csv
from glob import glob
@nyanshell
nyanshell / convert_to_xlsx.py
Created October 20, 2014 04:45
convert csv to xlsx
import glob
import csv
from xlsxwriter.workbook import Workbook
for csvfile in glob.glob("/data"):
workbook = Workbook(csvfile.rsplit(".")[0].split("/", 1)[-1] + '.xlsx')
worksheet = workbook.add_worksheet()
_format = workbook.add_format()
_format.set_pattern(1)
_format.set_bg_color('blue')
@nyanshell
nyanshell / Dockerfile
Last active August 29, 2015 14:08
configuration for mongodb testing environment run in docker
FROM ubuntu:latest
# Add 10gen official apt source to the sources list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
# Install MongoDB
RUN apt-get update
RUN apt-get install mongodb-10gen