Skip to content

Instantly share code, notes, and snippets.

View NigoroJr's full-sized avatar

Naoki Mizuno NigoroJr

  • Ohio, United States
View GitHub Profile
@NigoroJr
NigoroJr / link.bat
Last active October 16, 2016 16:31
Sets up Vim for Windows. Clones neobundle.vim and vimproc.vim, and builds necessary files for vimproc.vim
@NigoroJr
NigoroJr / brew.sh
Last active January 7, 2017 19:01
GNU-ify Mac OS X
#!/bin/sh
if [ `which brew | grep 'brew$'` = "" ]; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
fi
if [ ! -e ~/.zshrc_local -o `grep '\$(brew --prefix coreutils)/libexec/gnubin' ~/.zshrc_local` = "" ]; then
echo 'export PATH="$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH"' >> ~/.zshrc_local
fi
@NigoroJr
NigoroJr / ncurses_sample.cpp
Last active August 29, 2015 14:11
Sample program using ncurses library
#include <ncurses.h>
#include <unistd.h>
#include <string>
// Compile program with -lncursesw option
int main(int argc, char const* argv[]) {
WINDOW* win;
std::string mes = "♔ ♚ ♕ ♛ ♖ ♜ ♗ ♝ ♘ ♞ ♙ ♟";
@NigoroJr
NigoroJr / function_returns_ptr.cpp
Last active August 29, 2015 14:11
Sample of function that returns an allocated pointer
#include <iostream>
int* bar() {
int* ret = new int;
return ret;
}
int main() {
for (int i = 0; i < 10; i++) {
int ptr = *bar();
@NigoroJr
NigoroJr / git_aliases.sh
Last active August 29, 2015 14:12
Shell script for configuring git aliases
#!/bin/sh
CMD='git config --global alias'
add_alias() {
ALIAS=`eval $CMD.$1`
if [[ -z "$ALIAS" ]]; then
eval "$CMD.$1 $2"
elif [[ $ALIAS != $2 ]]; then
printf "%-4s already defined as %s\n" $1 $ALIAS
@NigoroJr
NigoroJr / sum.cpp
Created December 30, 2014 06:33
Problem 'sum' for the programming contest
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdio>
int main() {
int set = 1;
int num;
while (true) {
@NigoroJr
NigoroJr / map.cpp
Created December 30, 2014 06:57
Sample program for using maps and iterating through them.
#include <iostream>
#include <map>
#include <string>
#include <iterator>
#include <boost/foreach.hpp>
#include <utility>
typedef Pair std::pair<std::string, int>
int main() {
@NigoroJr
NigoroJr / test.rb
Created March 21, 2015 22:30
Ruby script that uses NoMethodError and Object#send to get to an existing method
#!/usr/bin/env ruby
class Class
def foo
puts "FOO!!"
return false
end
end
str = "foa"
@NigoroJr
NigoroJr / find_spindown.rb
Last active August 29, 2015 14:19
Quick-and-dirty script to find out the spin-down time of my external HDD
#!/usr/bin/env ruby
require 'benchmark'
# Access HDD (on /dev/sdb?)
# If it takes too long to respond, it has spun down
CMD = 'ls /data/Videos >/dev/null'
# Range of minutes to wait. Spin-down should be within this range
WAIT_MINS = [44, 45]
# If it takes longer than this (secnods), disk has spun down
#include <iostream>
#include <fstream>
#include <string>
int main(const int argc, char* const argv[]) {
std::streambuf* buf;
if (argc >= 2) {
std::cout << "Got two or more args" << std::endl;
// OK