Skip to content

Instantly share code, notes, and snippets.

View rollcabbage's full-sized avatar

Nicholas Lee rollcabbage

View GitHub Profile
@rollcabbage
rollcabbage / backup_to_nas.sh
Last active January 2, 2019 12:29
files or log files backup script; backup object and destination be defined by associative array
#!/bin/bash
#
# created by RiHaku on June 2015
#
# mount -t nfs -o rw,rsize=8192,wsize=8192,hard,intr,noatime,bg,nfsvers=3 10.51.0.91:/DMZ /mnt/data
# mount -t nfs -o rw,rsize=8192,wsize=8192,hard,intr,noatime,bg,nfsvers=3 10.51.0.91:/TRUST /mnt/data
#
# mount check; if not mounted, exit with status code
df -h | awk 'NR == 5 {print $1}' | grep 10.51.0.91 >/dev/null 2>&1
@rollcabbage
rollcabbage / abnormal_ip_check.sh
Created April 30, 2015 05:32
find abnormal ip from access logs
#!/bin/bash
#昨日の日付を定義
THIS_MONTH=`date -d 'this month' "+%Y%m"`
YESTERDAY=`date -d '2 day ago' "+%Y%m%d"`
#YESTERDAY=`date -d '1 day ago' "+%Y%m%d"`
#昨日のアクセスログを格納するファイルを特定する、存在しない場合終了
ACCESSLOG=`find /var/log/httpd/$THIS_MONTH/ -name "*_access.$YESTERDAY*" -type f`
if [ "$ACCESSLOG" = "" ]; then
from wsgiref.simple_server import make_server
import string
import os
def application(environ, start_response):
start_response('200 OK', [('Content-type', 'text/html')])
ftp_users = []
with open('/etc/passwd', 'r') as item:
@rollcabbage
rollcabbage / TextEditor.pyw
Last active November 25, 2016 04:32
A text editor can save and open text file. Need wxPython module.
import wx
def load(event):
file = open(filename.GetValue())
contents.SetValue(file.read())
file.close()
def save(event):
file = open(filename.GetValue(), 'w')
file.write(contents.GetValue())
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
data <- read.csv("******.csv")
#---------------------------------Preprocessor---------------------------------
#delete repetitive row
data <- data[-seq(1, length(data$ID), by=2), ]
data$PupilDiaX[data$PupilDiaX == "NULL"] <- 0
data$PupilDiaY[data$PupilDiaY == "NULL"] <- 0
normalize <- function(data){
ave <- mean(data)
max <- max(data)
min <- min(data)
return (data <- (data - ave) / max(max,min) + 0.5)
}
smoothing <- function(data, frame){