This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable | |
import org.apache.spark.{SparkContext, SparkConf} | |
import org.apache.spark.SparkContext._ | |
import org.apache.spark.mllib.clustering.{EMLDAOptimizer, OnlineLDAOptimizer, LDAModel, LocalLDAModel, DistributedLDAModel, LDA} | |
import org.apache.spark.mllib.linalg.{Vector, Vectors} | |
import org.apache.spark.rdd.RDD | |
import org.apache.spark.sql.SQLContext | |
import org.apache.spark.sql._ | |
import org.apache.spark.ml.feature.{Tokenizer, RegexTokenizer} | |
import org.apache.spark.ml.feature.{CountVectorizer, CountVectorizerModel} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//manager.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME); | |
manager.registerListener(this, s, 20000); //20000μsec(=50Hz) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df["time"] = pd.to_datetime(df.index , unit="ms") | |
df["time2"] =df.index | |
df["time3"] = df.time2.apply(lambda x: datetime.fromtimestamp(x/1000)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Network definition | |
class MLP(chainer.Chain): | |
def __init__(self, n_units, n_out): | |
super(MLP, self).__init__( | |
# the size of the inputs to each layer will be inferred | |
l1=L.Linear(None, n_units), # n_in -> n_units | |
l2=L.Linear(None, n_units), # n_units -> n_units | |
l3=L.Linear(None, n_out), # n_units -> n_out | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def set_debugger_org(): | |
if not sys.excepthook == sys.__excepthook__: | |
from IPython.core import ultratb | |
sys.excepthook = ultratb.FormattedTB(call_pdb=True) | |
def set_debugger_org_frc(): | |
from IPython.core import ultratb | |
sys.excepthook = ultratb.FormattedTB(call_pdb=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_cos_mat(mat_df1, mat_df2): | |
""" | |
Args: | |
pd.DataFrame: mat_df1, mat_df2 | |
The modals of mat_df1 column and mat_df2 column must be same! | |
Returns: | |
pd.DataFrame: cosign_simularity_matrix_df | |
""" | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub shrink_colums() | |
' ---------- 要設定ゾーン Start ---------- | |
NUM_COL_SET = 2 ' 2列1セット | |
HEADER_OFFSET = 1 ' ヘッダ行の行数 | |
FROM_SHEET_NAME = "Sheet1" ' コピー元のシート名 | |
TO_SHEET_NAME = "ColumnShrinked" ' コピー先のシート名 | |
' ---------- 要設定ゾーン End ---------- | |
Worksheets.Add after:=Worksheets(Worksheets.Count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Creating an SSH key for you..." | |
ssh-keygen -t rsa | |
echo "Please add this public key to Github \n" | |
echo "https://github.com/account/ssh \n" | |
read -p "Press [Enter] key after this..." | |
echo "Installing xcode-stuff" | |
xcode-select --install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
fourcc = cv2.VideoWriter_fourcc(*'MP4V') | |
out = cv2.VideoWriter('out.mp4',fourcc, 20.0, (640,480)) | |
#dinstance function | |
def distance(x,y): | |
import math | |
return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# same speed: $ bash ./mov2gif.sh hogehoge.mov | |
# X2 speed: $ bash ./mov2gif.sh hogehoge.mov 2 | |
INPUT_FILENAME=$1 | |
ARGSPEED=$2 | |
SPEED=${ARGSPEED:=1} | |
OUTPUT_FILENAME="$1-x${SPEED}.gif" |
OlderNewer