Skip to content

Instantly share code, notes, and snippets.

View mshr-h's full-sized avatar

Masahiro Hiramori mshr-h

View GitHub Profile
@mshr-h
mshr-h / Makefile
Created March 7, 2017 11:07
$HOME/local/src/Makefile
CC=clang
CXX=clang++
PWD=$(shell pwd)
JOBS=$(shell nproc)
.ONESHELL:
.PHONY: all
all: vim iverilog go
@mshr-h
mshr-h / init.sh
Last active March 31, 2017 08:46
Ubuntu setup script
# environmental parameters
BASEDIR=$HOME/local
PACKAGES="autoconf bison build-essential clang curl flex gettext git gperf libncurses5-dev lua5.3 python-setuptools ruby zsh"
LANG_PACKAGES="liblua5.1-dev libluajit-5.1-dev luajit python3-dev ruby-dev"
GUI_PACKAGES="bleachbit gnome-tweak-tool gtkwave ibus-mozc indicator-multiload libgtk2.0-dev qtcreator synaptic vlc xorg-dev"
GOPATH=$HOME/go
GOROOT=$HOME/local/src/go
PATH=$GOPATH/bin:$PATH
PATH=$GOROOT/bin:$PATH
#
@mshr-h
mshr-h / uninstall_windowsapps.ps1
Last active July 19, 2020 04:38
Uninstalling Windows 10 Apps
Get-AppxPackage 9E2F88E3.Twitter | Remove-AppxPackage
Get-AppxPackage Microsoft.3DBuilder | Remove-AppxPackage
Get-AppxPackage Microsoft.BingFinance | Remove-AppxPackage
Get-AppxPackage Microsoft.BingNews | Remove-AppxPackage
Get-AppxPackage Microsoft.BingSports | Remove-AppxPackage
Get-AppxPackage Microsoft.BingWeather | Remove-AppxPackage
Get-AppxPackage Microsoft.CommsPhone | Remove-AppxPackage
Get-AppxPackage Microsoft.Getstarted | Remove-AppxPackage
Get-AppxPackage Microsoft.Messaging | Remove-AppxPackage
Get-AppxPackage Microsoft.MicrosoftOfficeHub | Remove-AppxPackage
@mshr-h
mshr-h / install-iverilog.sh
Last active January 15, 2016 06:30
Install iverilog
#!/bin/bash
if [ $# -eq 1 ]; then
INSTALLPATH=$1
else
INSTALLPATH=`pwd`/local
fi
CORE=`expr \`nproc\` + 1`
@mshr-h
mshr-h / montyhall.py
Last active June 6, 2017 20:56
montyhall problem simulation
#-*- encoding: utf-8 -*-
import random
def open_door(doors, answer, choice):
rest_doors = [x for x in doors if x is not choice]
opened_door = random.choice([x for x in rest_doors if x is not answer])
return [x for x in doors if x is not opened_door]
doors = [1, 2, 3]
@mshr-h
mshr-h / dp.py
Last active January 5, 2016 07:22
Knapsack problem
#-*- coding: utf-8 -*-
import sys
print("Input the item values:")
c = map(int, sys.stdin.readline().split(" "))
c.insert(0, 0)
print("Input the item sizes:")
a = map(int, sys.stdin.readline().split(" "))
a.insert(0, 0)
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int h,w;
int width;
int height;
int total;
size_t frame_size;
import re
import math
def getwords(doc):
splitter = re.compile('\\W*')
# Split the words by non-alpha characters
words = [s.lower() for s in splitter.split(doc)
if len(s) > 2 and len(s) < 20]
from pysqlite2 import dbapi2 as sqlite
import re
import math
def getwords(doc):
splitter = re.compile('\\W*')
# Split the words by non-alpha characters
words = [s.lower() for s in splitter.split(doc)
if len(s) > 2 and len(s) < 20]
@mshr-h
mshr-h / malloc.c
Created June 17, 2015 02:52
simple malloc implementation
/* Include the sbrk function */
#include <unistd.h>
int has_initialized = 0;
void *managed_memory_start;
void *last_valid_address;
void malloc_init() { /* grab the last valid address from the OS*/
last_valid_address = sbrk(0);
/* we don't have any memory to manage yet, so