Skip to content

Instantly share code, notes, and snippets.

View yutannihilation's full-sized avatar
🍣
Nobody loves you

Hiroaki Yutani yutannihilation

🍣
Nobody loves you
View GitHub Profile
@yutannihilation
yutannihilation / freebsd91.json
Last active December 22, 2015 13:48
Simple JSON definition file for Packer.
{
"builders": [
{
"type": "virtualbox",
"vm_name": "freebsd-packer",
"boot_wait": "10s",
"disk_size": 10240,
"guest_os_type": "FreeBSD_64",
"iso_checksum": "f0a320fd52383c42649d48ea545915a9",
"iso_checksum_type": "md5",
{
"builders": [
{
"type": "virtualbox-iso",
"vm_name": "freebsd100-packer",
"boot_wait": "10s",
"disk_size": 10240,
"guest_os_type": "FreeBSD_64",
"iso_checksum": "fd25619fa0d69c29bea8347b1070ac75",
"iso_checksum_type": "md5",
$targetsfile_loc = "C:\Path\To\Script_Dir\vagrant.list"
$vagrant_cmd = "C:\HashiCorp\Vagrant\bin\vagrant.exe"
$putty_cmd = "C:\Path\To\putty.exe"
$current_loc = Get-Location
$targets = Get-Content $targetsfile_loc
ForEach ($target in $targets) {
$vagrant_dir,$putty_prof = $target.split(",")
Set-Location $vagrant_dir -PassThru
#cloud-config
hostname: HOSTNAME
write_files:
- path: /etc/iptables.rules
permissions: 0644
content: |
*filter
:INPUT DROP [13:1170]
@yutannihilation
yutannihilation / 00ggplot2_options.R
Last active August 29, 2015 14:08
options of ggplot2: fixing range and colors
library(ggplot2)
library(animation)
library(dplyr)
set.seed(100)
data <- data.frame(value = rnorm(1000, mean = 5, sd = sqrt(5)))
### continuous-scale axis ###
# BAD EXAMPLE: Ranges are changing too fast...
@yutannihilation
yutannihilation / rcpp_hexdump.cpp
Last active August 29, 2015 14:10
Rcpp hexdump
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
std::vector<std::string> rcpp_hello_world(std::vector<std::string> strings) {
for(std::vector<std::string>::iterator s_it = strings.begin(); s_it != strings.end(); ++s_it) {
std::vector<unsigned char> c((*s_it).begin(), (*s_it).end());
int length = c.size();
@yutannihilation
yutannihilation / nippon_vs_halfwidthr_vs_stringi.md
Last active August 29, 2015 14:10
benchmarks of conversion from 全角 to 半角

Libraries and constants

library(halfwidthr)
library(Nippon)
library(stringi)
library(microbenchmark)

a <- rep(zenkaku$number, 10000)
zen <- paste0(c(zenkaku$number, zenkaku$lower, zenkaku$upper), collapse = "")
@yutannihilation
yutannihilation / plus.R
Created December 5, 2014 16:00
speed of `base::+` and `.Primitive("+")`
> a <- runif(1000,1,10)
> microbenchmark(base::`+`(a, a), .Primitive("+")(a,a))
Unit: microseconds
expr min lq mean median uq max neval
base::`+`(a, a) 14.527 16.483 28.85315 19.556 20.6730 716.852 100
.Primitive("+")(a, a) 5.308 6.147 9.96258 9.220 10.1975 49.448 100
@yutannihilation
yutannihilation / named_argument.md
Last active August 29, 2015 14:11
data.frame is tricky!

When specifying named arguments, you have to use =, instead of <-.

This code

data.frame(x2 <- x2, y2 <- y2)

is actually iterpreted like this:

@yutannihilation
yutannihilation / yrmcds_similatity.md
Last active August 29, 2015 14:11
word distance of yrmcds and 夜マクド