Skip to content

Instantly share code, notes, and snippets.

@Shusei-E
Shusei-E / r_rng_save.R
Last active May 8, 2023 18:50
R: Saving Random State
set.seed(225)
rnorm(5)
rnorm(5)
rnorm(5)
rand_state <- .GlobalEnv$.Random.seed
saveRDS(list(rand_state = rand_state), "rand_state.rds")
rnorm(5) # [1] 0.55203151 0.08414507 1.92445918 -0.65374544 1.42059484
.GlobalEnv$.Random.seed <- readRDS("rand_state.rds")$rand_state
rnorm(5) # [1] 0.55203151 0.08414507 1.92445918 -0.65374544 1.42059484
@Shusei-E
Shusei-E / color.R
Created July 8, 2022 14:25
color code
color_brewer <- function(ids = NULL, rev = TRUE) {
# RColorBrewer::brewer.pal(n = 7, name = "Set1")
colour <- c(
"#377EB8",
"#E41A1C",
"#4DAF4A",
"#F7D94C",
"#984EA3",
"#A65628",
"#FF7F00",
@Shusei-E
Shusei-E / git.migrate
Created March 6, 2019 14:45 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@Shusei-E
Shusei-E / bccEmail.py
Created July 8, 2016 08:12
Send BCC e-mail via Gmail by Python
import smtplib
from email.mime.text import MIMEText
from email.header import decode_header
from email.header import Header
import pandas as pd
import random
import time
# タイトル
@Shusei-E
Shusei-E / coefficent_plot_walkthrough.R
Created July 4, 2016 11:39 — forked from dsparks/coefficent_plot_walkthrough.R
A coefficient plot for multiple models
doInstall <- TRUE
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
ANES <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/ANES.csv")
ANES <- ANES[ANES$year == 2008, -c(1, 11, 17)] # Limit to just 2008 respondents,
head(ANES) # remove some non-helpful variables
# Fit several models with the same DV:
@Shusei-E
Shusei-E / pdf_insertBlank.py
Created June 19, 2016 22:27
main pdfファイルのページに対して交互に空白ページを挿入
import argparse
from PyPDF2 import PdfFileWriter, PdfFileReader
import os
def main(main_path, blank_path):
output = PdfFileWriter()
main_file = PdfFileReader(open(main_path, "rb"))
blank_file = PdfFileReader(open(blank_path, "rb"))
@Shusei-E
Shusei-E / filelist.cpp
Created June 12, 2016 06:50
Make File List with specific extension in C++
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <dirent.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
using namespace std;
@Shusei-E
Shusei-E / read_matrix.cpp
Last active May 4, 2016 04:47
Eigen Read Files
// Original Code http://goo.gl/P0sED6
#include <iostream>
#include <fstream>
#include <string>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
@Shusei-E
Shusei-E / DataGenFixedVarianece.cpp
Last active April 28, 2016 01:58
DataGen with fixed variance
#include <iostream>
#include <fstream>
#include <string>
#include <random>
// Eigen
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
\ProvidesPackage{beamerthemeI6pd2} % this style was created by Thomas Deselaers an Philippe Dreuw
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tangocolors}
\selectcolormodel{cmyk}
\mode<presentation>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamercolor{headline}{fg=tabutter,bg=ta2chameleon}