initial push

This commit is contained in:
Steve Burdick 2026-10-02 14:30:40 -07:00
commit 693f2986ae
44 changed files with 1953 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#!/usr/bin/python
# 2013-01-31 sburdick
# To solve a Car Talk puzzler
# Goal is to distribute $1000 into 10 envelopes such that when asked for any quantity of whole dollars up to $1000, money can be distributed by paying with any combination of the 10 envelopes without changing their contents
#
# This test proves that distribution of 489,256,256,128,64,32,16,8,4,2,1 works.
import sys
# Fetch command line argument
try:
goal = int(sys.argv[1])
except IndexError:
sys.exit("User did not supply an argument.")
except ValueError:
sys.exit("User's argument was not an integer.")
# Validate integer given as command line argument (goal)
if (goal < 1) | (goal > 1000):
sys.exit("Integer was not within range of 1-1000")
array = [489,256,256,128,64,32,16,8,4,2,1]
remainder = goal
for x in array:
if remainder >= x:
# print str(remainder) + " - " + str(x) + " = " + str(remainder - x)
remainder -= x
if remainder == 0:
# sys.exit("I WON solving for " + str(goal) + "!")
sys.exit()
sys.exit("I LOST solving for " + str(goal) + "...")

View File

@ -0,0 +1,157 @@
#!/usr/bin/python
# Solves puzzles for Android game Shot (http://www.androidzoom.com/android_games/brain_puzzle/shot-puzzle_xina.html)
# Populate matrix "puzzle" with 1s to represent ball locations
import copy
class wizard:
def __init__(this,puzzle,trail):
# print "----------------------------------------------"
# print "New spawn started with this puzzle:"
# for i in puzzle:
# print i
balls = 0
for x in puzzle:
for y in x:
if y == 1:
balls += 1
# print "Total balls: " + str(balls)
if balls == 1:
columns = len(trail[0])
rowcount = 0
step = 0
# print "ORIGINAL PUZZLE"
for i in trail:
rowcount += 1
print i
if rowcount == columns:
rowcount = 0
step += 1
# print "STEP #" + str(step)
# print "END TRAIL"
exit("Win!")
countx = county = 0
for x in puzzle: # for each row
for y in x: # for each column within each row
if y == 1: # if it found a ball
this.shootball(puzzle,countx,county,trail)
county += 1
county = 0
countx += 1
# print "FAILED...death."
# print "Another wizard died"
# print "----------------------"
def shootball(this,puzzle,ballx,bally,trail):
this.tryright(puzzle,ballx,bally,trail)
this.tryleft(puzzle,ballx,bally,trail)
this.tryup(puzzle,ballx,bally,trail)
this.trydown(puzzle,ballx,bally,trail)
def tryright(this,puzzle,ballx,bally,trail):
workingpuzzle = copy.deepcopy(puzzle)
probex = ballx
probey = bally
numcolumns = len(workingpuzzle[probex])
while (probey < numcolumns - 1):
probey += 1
if workingpuzzle[probex][probey] == 1:
if probey - 1 == bally:
return # if ball is adjacent, can't hit it
trailadd = "(" + str(ballx) + "," + str(bally) + ") RIGHT"
workingtrail = copy.deepcopy(trail)
workingtrail.append(trailadd)
workingpuzzle[ballx][bally] = 0 # remove original ball
while probey < numcolumns:
if workingpuzzle[ballx][probey] == 1:
workingpuzzle[ballx][probey - 1] = 1
workingpuzzle[ballx][probey] = 0
probey += 1
nextwizard = wizard(workingpuzzle,workingtrail)
def tryleft(this,puzzle,ballx,bally,trail):
workingpuzzle = copy.deepcopy(puzzle)
probex = copy.deepcopy(ballx)
probey = copy.deepcopy(bally)
numcolumns = len(workingpuzzle[probex])
while (probey > 0):
probey -= 1
if workingpuzzle[probex][probey] == 1:
if probey + 1 == bally: # if ball is adjacent, can't hit it
return
trailadd = "(" + str(ballx) + "," + str(bally) + ") LEFT"
workingtrail = copy.deepcopy(trail)
workingtrail.append(trailadd)
workingpuzzle[ballx][bally] = 0 # remove original ball
while probey >= 0:
if workingpuzzle[ballx][probey] == 1:
workingpuzzle[ballx][probey + 1] = 1
workingpuzzle[ballx][probey] = 0
probey -= 1
nextwizard = wizard(workingpuzzle,workingtrail)
def trydown(this,puzzle,ballx,bally,trail):
workingpuzzle = copy.deepcopy(puzzle)
probex = ballx
probey = bally
numrows = len(workingpuzzle)
while (probex < numrows - 1):
probex += 1
if workingpuzzle[probex][probey] == 1:
if probex - 1 == ballx:
return # if ball is adjacent, can't hit it
trailadd = "(" + str(ballx) + "," + str(bally) + ") DOWN"
workingtrail = copy.deepcopy(trail)
workingtrail.append(trailadd)
workingpuzzle[ballx][bally] = 0 # remove original ball
while probex < numrows:
if workingpuzzle[probex][bally] == 1:
workingpuzzle[probex -1][bally] = 1
workingpuzzle[probex][bally] = 0
probex += 1
nextwizard = wizard(workingpuzzle,workingtrail)
def tryup(this,puzzle,ballx,bally,trail):
workingpuzzle = copy.deepcopy(puzzle)
probex = copy.deepcopy(ballx)
probey = copy.deepcopy(bally)
numrows = len(workingpuzzle)
while (probex > 0):
probex -= 1
if workingpuzzle[probex][probey] == 1:
if probex + 1 == ballx: # if ball is adjacent, can't hit it
return
trailadd = "(" + str(ballx) + "," + str(bally) + ") UP"
workingtrail = copy.deepcopy(trail)
workingtrail.append(trailadd)
workingpuzzle[ballx][bally] = 0 # remove original ball
while probex >= 0:
if workingpuzzle[probex][bally] == 1:
workingpuzzle[probex + 1][bally] = 1
workingpuzzle[probex][bally] = 0
probex -= 1
nextwizard = wizard(workingpuzzle,workingtrail)
puzzle = [ [0,0,0,0,0,0,0] ,
[0,0,0,0,0,0,0] ,
[0,0,0,0,0,0,0] ,
[0,0,0,0,0,0,0] ,
[0,0,0,0,0,0,0] ,
[0,0,0,0,0,0,0] ,
[0,0,0,0,0,0,0] ]
firstwizard = wizard(puzzle,["Solution:"])
#print "firstwizard died"

5
bashrc.txt Normal file
View File

@ -0,0 +1,5 @@
alias engage1='ssh -D 10000 -L 3389:10.133.23.220:3389 -p 2222 its@203.215.132.7'
alias engage2='xfreerdp /kbd:0x00000411 /clipboard /size:1440x1000 /u:sburdick@servcorp.prd /p:RichMalt2020 /v:10.133.23.223 /cert-ignore'
alias ll='ls -lh'
alias vim=vim.tiny
alias puke='dd if=/dev/urandom bs=1M count=1 2>/dev/null |base64 |tail -2|head -1'

119
bmsh_parse-cli/parse_app.py Normal file
View File

@ -0,0 +1,119 @@
#!/usr/bin/python2.7
from PIL import Image
from urllib import urlopen
import sys
import StringIO
def gen_sig(x_start, y_start): # returns black pixels
sig_0 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [0, 5], [1, 5], [6, 5], [7, 5], [0, 6], [1, 6], [6, 6], [7, 6], [0, 7], [1, 7], [6, 7], [7, 7], [0, 8], [1, 8], [6, 8], [7, 8], [0, 9], [1, 9], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
sig_1 = [[3, 0], [4, 0], [1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [3, 3], [4, 3], [3, 4], [4, 4], [3, 5], [4, 5], [3, 6], [4, 6], [3, 7], [4, 7], [3, 8], [4, 8], [3, 9], [4, 9], [3, 10], [4, 10], [3, 11], [4, 11], [3, 12], [4, 12], [3, 13], [4, 13], [3, 14], [4, 14]]
sig_2 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [5, 5], [6, 5], [7, 5], [4, 6], [5, 6], [6, 6], [4, 7], [5, 7], [3, 8], [4, 8], [5, 8], [2, 9], [3, 9], [4, 9], [2, 10], [3, 10], [1, 11], [2, 11], [3, 11], [0, 12], [1, 12], [2, 12], [0, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [0, 14], [1, 14], [2, 14], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14]]
sig_4 = [[5, 0], [6, 0], [5, 1], [6, 1], [4, 2], [5, 2], [6, 2], [4, 3], [5, 3], [6, 3], [3, 4], [4, 4], [5, 4], [6, 4], [3, 5], [4, 5], [5, 5], [6, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [2, 7], [3, 7], [5, 7], [6, 7], [1, 8], [2, 8], [3, 8], [5, 8], [6, 8], [1, 9], [2, 9], [5, 9], [6, 9], [0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [5, 12], [6, 12], [5, 13], [6, 13], [5, 14], [6, 14]]
sig_6 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [0, 7], [1, 7], [2, 7], [5, 7], [6, 7], [7, 7], [0, 8], [1, 8], [6, 8], [7, 8], [0, 9], [1, 9], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
sig_8 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [0, 5], [1, 5], [2, 5], [5, 5], [6, 5], [7, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [0, 8], [1, 8], [2, 8], [5, 8], [6, 8], [7, 8], [0, 9], [1, 9], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
char_width = 8
char_height = 15
space = 2
english_sig = ""
for digit_num in range(1,4):
this_sig = []
for check_y in range(y_start, y_start + char_height):
for check_x in range(x_start, x_start + char_width):
(curr_r, curr_g, curr_b) = pix[check_x,check_y]
if (curr_r, curr_g, curr_b) == (0,0,0): # if pixel is black
this_sig.append([check_x - x_start,check_y - y_start])
for ref_sig in (["0",sig_0], ["1",sig_1], ["2",sig_2], ["4",sig_4], ["6",sig_6], ["8",sig_8]): # array of known sigs added to arrays with element [0] being the English name of the number
if this_sig == ref_sig[1]:
english_sig += ref_sig[0]
x_start += char_width + space
return int(english_sig)
def detect_y_axis_labels(): # Detect the y_axis labels
x_offset = 38 # 38 is x coordinate of 1st character of y-axis labels
y_axis_labels = []
for y in (29, 75, 122, 168, 214, 260, 306): # y coordinates of y-axis kWh labels
# print "Captain, our sensors detected the number: " + gen_sig(38,y)
y_axis_labels.append([gen_sig(38,y), y + 7]) # adding 7 to mark y-coord of cooresponding black line (always 7 pixels lower than start of text label)
return y_axis_labels
def detect_monthly_totals(): # Read the green bars and push to array
# static variables
image_dimy = 350 # height of image
(green_r, green_g, green_b) = (130,185,6) # RGB values of the deepest green value, used to detect bar heights
column_offset = 119 # starting x coord of 1st graph in bar graph
column_increment = 55 # spare between bars
month = 1
monthly_totals = []
check_x = column_offset
for check_x in range(column_offset, column_offset + (12 * column_increment), column_increment): # LOOP to check a year
for check_y in range(36,image_dimy): # LOOP to check a month
(curr_r, curr_g, curr_b) = pix[check_x,check_y]
if (curr_r, curr_g, curr_b) == (green_r, green_g, green_b):
# print "Month " + str(month) + " total: y=" + str(check_y)
monthly_totals.append([month,check_y])
break
month += 1
return monthly_totals
def calculate_kWh_per_month(monthly_totals, y_axis_labels):
monthly_kWh = []
for [month_num, month_y] in monthly_totals: # loop for each month
for x in range(0, len(y_axis_labels)): # x = [int kWh, int y-axis]:
if (y_axis_labels[x][1] > month_y and y_axis_labels[x-1][1] < month_y):
kWh_label_increment = y_axis_labels[x-1][0] - y_axis_labels[x][0]
y_label_increment = y_axis_labels[x][1] - y_axis_labels[x-1][1]
kWh_per_pixel = float(kWh_label_increment) / float(y_label_increment)
kWh_bonus = kWh_per_pixel * (y_axis_labels[x][1] - month_y)
kWh_this_month = kWh_bonus + float(y_axis_labels[x][0])
monthly_kWh.append([month_num, round(kWh_this_month,2)])
return monthly_kWh
def fetch_bmp_url(year):
url_base = "http://192.168.0.11/pc/"
filename_header = "graph_pc.bmp?"
filename_header_len = len(filename_header)
html = urlopen(url_base + "?befor_hs_y_pc.html+"+year).read()
html = html.split("\r")
for line in html:
pos_of_graphic = line.find(filename_header)
if pos_of_graphic == -1:
continue
bmp_filename = line[pos_of_graphic:pos_of_graphic+filename_header_len+14] # extract substring contai$
return url_base + bmp_filename
if len(sys.argv) == 2:
year = sys.argv[1]
else:
sys.exit("Please feed me a 4-digit year as an argument.")
bmp_url = fetch_bmp_url(year)
bmp = StringIO.StringIO(urlopen(bmp_url).read())
try:
im = Image.open(bmp)
except IOError as errno:
sys.exit("Error opening image:\n" + str(errno))
pix = im.load() # pix is array containing pixel data
monthly_totals = detect_monthly_totals()
#print "Monthly totals [month #, kWh]:"
#print monthly_totals
y_axis_labels = detect_y_axis_labels()
#print "y-axis label heights:"
#print y_axis_labels
monthly_kWh = calculate_kWh_per_month(monthly_totals, y_axis_labels)
for [month_num, month_kWh] in monthly_kWh:
print "Month " + str(month_num) + ": " + str(month_kWh) + " kWh"

View File

@ -0,0 +1,191 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image
from urllib import urlopen
import datetime
import StringIO
import sys
import wx
import wx.grid
class SharpNinja:
def return_monthly_kWh_cuz_python_is_a_bitch(self):
return self.monthly_kWh
def __init__(self, year):
bmp_url = self.fetch_bmp_url(year)
bmp = StringIO.StringIO(urlopen(bmp_url).read())
try:
im = Image.open(bmp)
except IOError as errno:
sys.exit("Error opening image:\n" + str(errno))
pix = im.load() # pix is array containing pixel data
monthly_totals = self.detect_monthly_totals(pix)
#print "Monthly totals [month #, kWh]:"
y_axis_labels = self.detect_y_axis_labels(pix)
#print "y-axis label heights:"
#print y_axis_labels
self.monthly_kWh = self.calculate_kWh_per_month(monthly_totals, y_axis_labels)
output = ''
for [month_num, month_kWh] in self.monthly_kWh:
print "Month " + str(month_num) + ": " + str(month_kWh) + " kWh"
output += "Month " + str(month_num) + ": " + str(month_kWh) + " kWh\n"
def gen_sig(self, x_start, y_start, pix): # returns black pixels
sig_0 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [0, 5], [1, 5], [6, 5], [7, 5], [0, 6], [1, 6], [6, 6], [7, 6], [0, 7], [1, 7], [6, 7], [7, 7], [0, 8], [1, 8], [6, 8], [7, 8], [0, 9], [1, 9], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
sig_1 = [[3, 0], [4, 0], [1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [3, 3], [4, 3], [3, 4], [4, 4], [3, 5], [4, 5], [3, 6], [4, 6], [3, 7], [4, 7], [3, 8], [4, 8], [3, 9], [4, 9], [3, 10], [4, 10], [3, 11], [4, 11], [3, 12], [4, 12], [3, 13], [4, 13], [3, 14], [4, 14]]
sig_2 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [5, 5], [6, 5], [7, 5], [4, 6], [5, 6], [6, 6], [4, 7], [5, 7], [3, 8], [4, 8], [5, 8], [2, 9], [3, 9], [4, 9], [2, 10], [3, 10], [1, 11], [2, 11], [3, 11], [0, 12], [1, 12], [2, 12], [0, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [0, 14], [1, 14], [2, 14], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14]]
sig_3 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [5, 5], [6, 5], [7, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [5, 8], [6, 8], [7, 8], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
sig_4 = [[5, 0], [6, 0], [5, 1], [6, 1], [4, 2], [5, 2], [6, 2], [4, 3], [5, 3], [6, 3], [3, 4], [4, 4], [5, 4], [6, 4], [3, 5], [4, 5], [5, 5], [6, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [2, 7], [3, 7], [5, 7], [6, 7], [1, 8], [2, 8], [3, 8], [5, 8], [6, 8], [1, 9], [2, 9], [5, 9], [6, 9], [0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [5, 12], [6, 12], [5, 13], [6, 13], [5, 14], [6, 14]]
sig_5 = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [0, 3], [1, 3], [0, 4], [1, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [0, 7], [1, 7], [2, 7], [5, 7], [6, 7], [7, 7], [0, 8], [1, 8], [6, 8], [7, 8], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
sig_6 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [0, 7], [1, 7], [2, 7], [5, 7], [6, 7], [7, 7], [0, 8], [1, 8], [6, 8], [7, 8], [0, 9], [1, 9], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
sig_8 = [[2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [6, 3], [7, 3], [0, 4], [1, 4], [6, 4], [7, 4], [0, 5], [1, 5], [2, 5], [5, 5], [6, 5], [7, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [0, 8], [1, 8], [2, 8], [5, 8], [6, 8], [7, 8], [0, 9], [1, 9], [6, 9], [7, 9], [0, 10], [1, 10], [6, 10], [7, 10], [0, 11], [1, 11], [6, 11], [7, 11], [0, 12], [1, 12], [2, 12], [5, 12], [6, 12], [7, 12], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [2, 14], [3, 14], [4, 14], [5, 14]]
char_width = 8
char_height = 15
space = 2
english_sig = ""
for digit_num in range(1,4):
this_sig = []
for check_y in range(y_start, y_start + char_height):
for check_x in range(x_start, x_start + char_width):
(curr_r, curr_g, curr_b) = pix[check_x,check_y]
if (curr_r, curr_g, curr_b) == (0,0,0): # if pixel is black
this_sig.append([check_x - x_start,check_y - y_start])
for ref_sig in (["0",sig_0], ["1",sig_1], ["2",sig_2], ["3",sig_3], ["4",sig_4], ["5",sig_5], ["6",sig_6], ["8",sig_8]): # array of known sigs added to arrays with element [0] being the English name of the number
if this_sig == ref_sig[1]:
english_sig += ref_sig[0]
x_start += char_width + space
return int(english_sig)
def detect_y_axis_labels(self, pix): # Detect the y_axis labels
x_offset = 38 # 38 is x coordinate of 1st character of y-axis labels
y_axis_labels = []
for y in (29, 75, 122, 168, 214, 260, 306): # y coordinates of y-axis kWh labels
# print "Captain, our sensors detected the number: " + gen_sig(38,y)
y_axis_labels.append([self.gen_sig(38,y,pix), y + 7]) # adding 7 to mark y-coord of cooresponding black line (always 7 pixels lower than start of text label)
return y_axis_labels
def detect_monthly_totals(self, pix): # Read the green bars and push to array
# static variables
image_dimy = 350 # height of image
(green_r, green_g, green_b) = (130,185,6) # RGB values of the deepest green value, used to detect bar heights
column_offset = 119 # starting x coord of 1st graph in bar graph
column_increment = 55 # spare between bars
month = 1
monthly_totals = []
check_x = column_offset
for check_x in range(column_offset, column_offset + (12 * column_increment), column_increment): # LOOP to check a year
for check_y in range(36,image_dimy): # LOOP to check a month
(curr_r, curr_g, curr_b) = pix[check_x,check_y]
if (curr_r, curr_g, curr_b) == (green_r, green_g, green_b):
# print "Month " + str(month) + " total: y=" + str(check_y)
monthly_totals.append([month,check_y])
break
if check_y == image_dimy - 1: # if a green bar was not discovered, insert 0 for the monthly total
monthly_totals.append([month,0])
month += 1
return monthly_totals
def calculate_kWh_per_month(self, monthly_totals, y_axis_labels):
monthly_kWh = []
for [month_num, month_y] in monthly_totals: # loop for each month
if month_y == 0:
monthly_kWh.append([month_num, 0])
continue
for x in range(0, len(y_axis_labels)): # x = [int kWh, int y-axis]:
if (y_axis_labels[x][1] > month_y and y_axis_labels[x-1][1] < month_y):
kWh_label_increment = y_axis_labels[x-1][0] - y_axis_labels[x][0]
y_label_increment = y_axis_labels[x][1] - y_axis_labels[x-1][1]
kWh_per_pixel = float(kWh_label_increment) / float(y_label_increment)
kWh_bonus = kWh_per_pixel * (y_axis_labels[x][1] - month_y)
kWh_this_month = kWh_bonus + float(y_axis_labels[x][0])
monthly_kWh.append([month_num, round(kWh_this_month,2)])
return monthly_kWh
def fetch_bmp_url(self, year):
url_base = "http://192.168.0.11/pc/"
filename_header = "graph_pc.bmp?"
filename_header_len = len(filename_header)
html = urlopen(url_base + "?befor_hs_y_pc.html+"+year).read()
html = html.split("\r")
for line in html:
pos_of_graphic = line.find(filename_header)
if pos_of_graphic == -1:
continue
bmp_filename = line[pos_of_graphic:pos_of_graphic+filename_header_len+14] # extract substring contai$
return url_base + bmp_filename
class MyFrame(wx.Frame):
def EvtComboBox(self, event):
year = event.GetString()
cached_record = self.output_cache.get(year)
if cached_record:
output = cached_record
else:
MySharpNinja = SharpNinja(year)
output = MySharpNinja.return_monthly_kWh_cuz_python_is_a_bitch()
for [month,kWh] in output:
self.grid.SetCellValue(month - 1, 0, str(kWh))
self.grid.SetReadOnly(month -1 , 0, True)
self.grid.SetCellAlignment(month - 1, 0, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
self.output_cache[year] = output
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(350, 600))
first_year = 2011
self.output_cache = {}
# Container
vbox = wx.BoxSizer(wx.VERTICAL)
# Label
label = wx.StaticText(self, label="年度を選んでください")
vbox.Add(label, 0, wx.ALIGN_CENTER | wx.ALL, 30)
# Dropdown
now = datetime.datetime.now()
cb_choices = []
for x in range(now.year, now.year - 7, -1): # display last 7 years
if x >= first_year:
cb_choices.append(str(x))
cb = wx.ComboBox(self, 1, choices=cb_choices)
wx.EVT_COMBOBOX(self, 1, self.EvtComboBox)
vbox.Add(cb, 0, wx.ALIGN_CENTER | wx.ALL, 10)
# Grid
self.grid = wx.grid.Grid(self)
self.grid.CreateGrid(12, 1)
self.grid.SetColLabelValue(0, "kWh")
self.grid.SetColMinimalAcceptableWidth(80)
for x in range(1,13):
self.grid.SetRowLabelValue(x - 1,str(x) + "月")
self.grid.Fit()
vbox.Add(self.grid, 0, wx.ALIGN_CENTER | wx.ALL, 10)
# Open the curtain
self.SetSizer(vbox)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'BM: 年間発電計算ツール')
frame.Show(True)
return True
app = MyApp(0)
app.MainLoop()

BIN
draw_circle-cli/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,37 @@
#!/usr/bin/env python
from math import sin,cos,radians
radius = 17
steps = 90
angle_increment = 90/steps
grid = []
for n in range(0,(90/angle_increment) + 1):
angle = n * angle_increment
x = int(sin(radians(angle)) * radius)
y = int(cos(radians(angle)) * radius)
if (x,y) not in grid:
grid.append((x,y))
rows = []
for row in range(radius,-1,-1):
thisrow = ""
# top half
for col in range(0,radius+1):
if(col,row) in grid:
thisrow += "O"
else:
thisrow += "."
# mirror thisrow and prefix it to thisrow (add top left quadrant)
thisrow = thisrow[1:radius+1][::-1] + thisrow
rows.append(thisrow)
#print top hemisphere
for row in rows:
print row
#print bottom hemisphere (reverse it -> chop first element off)
for row in rows[::-1][1:radius+1]:
print row

BIN
ibm_laptop/mysqldump.gz Normal file

Binary file not shown.

BIN
ibm_laptop/www_root.tar.gz Normal file

Binary file not shown.

33
id3_renamer.pl Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env perl
use v5.18;
use Data::Dumper;
opendir my $dh, '.';
my @files = readdir $dh;
closedir $dh;
for my $file (@files){
my %bag;
next unless $file =~ m/\.mp3$/i;
my $id3out = `id3 "$file"`;
for (split "\n", $id3out){
if(m/Track\: (\d+)/){
$bag{'track'} = $1;
$bag{'track'} =~ s/^(\d)$/0\1/;
};
if(m/Title\: (.+)/){$bag{'title'} = $1;
$bag{'title'} =~ s/\s*$//;
$bag{'title'} =~ tr/ /_/;
$bag{'title'} =~ tr/(/-/;
$bag{'title'} =~ tr/)//;
$bag{'title'} =~ s/\//_a.k.a._/g;
};
}
next unless defined $bag{'track'} && defined $bag{'title'};
my $newfile = sprintf "%s-%s.mp3",
$bag{'track'},
$bag{'title'}
;
printf "mv \"%s\" \"%s\"\n", $file, $newfile;
}

33
id3_renamer.pl.20190820 Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env perl
use v5.18;
use Data::Dumper;
opendir my $dh, '.';
my @files = readdir $dh;
closedir $dh;
for my $file (@files){
my %bag;
next unless $file =~ m/\.mp3$/i;
my $id3out = `id3 "$file"`;
for (split "\n", $id3out){
if(m/Track\: (\d+)/){
$bag{'track'} = $1;
$bag{'track'} =~ s/^(\d)$/0\1/;
};
if(m/Title\: (.+)/){$bag{'title'} = $1;
$bag{'title'} =~ s/\s*$//;
$bag{'title'} =~ tr/ /_/;
$bag{'title'} =~ tr/(/-/;
$bag{'title'} =~ tr/)//;
$bag{'title'} =~ s/\//_a.k.a._/g;
};
}
next unless defined $bag{'track'} && defined $bag{'title'};
my $newfile = sprintf "%s-%s.mp3",
$bag{'track'},
$bag{'title'}
;
printf "mv \"%s\" \"%s\"\n", $file, $newfile;
}

33
id3_renamer.pl.v1 Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env perl
use v5.18;
use Data::Dumper;
opendir my $dh, '.';
my @files = readdir $dh;
closedir $dh;
for my $file (@files){
my %bag;
next unless $file =~ m/\.mp3$/i;
my $id3out = `id3 "$file"`;
for (split "\n", $id3out){
if(m/Track\: (\d+)/){
$bag{'track'} = $1;
$bag{'track'} =~ s/^(\d)$/0\1/;
};
if(m/Title\: (.+)/){$bag{'title'} = $1;
$bag{'title'} =~ s/\s*$//;
$bag{'title'} =~ tr/ /_/;
$bag{'title'} =~ tr/(/-/;
$bag{'title'} =~ tr/)//;
$bag{'title'} =~ s/\//_a.k.a._/g;
};
}
next unless defined $bag{'track'} && defined $bag{'title'};
my $newfile = sprintf "%s-%s.mp3",
$bag{'track'},
$bag{'title'}
;
printf "mv \"%s\" \"%s\"\n", $file, $newfile;
}

View File

@ -0,0 +1,45 @@
import java.applet.*;
import java.awt.*;
public class CounterThread extends Applet implements Runnable
{
Thread t;
int Count;
public void init()
{
Count=0;
t=new Thread(this);
t.start();
}
public boolean mouseDown(Event e,int x, int y)
{
t.stop();
return true;
}
public void run()
{
while(true)
{
Count++;
repaint();
try {
t.sleep(10);
} catch (InterruptedException e) {}
}
}
public void paint(Graphics g)
{
g.drawString(Integer.toString(Count),10,10);
System.out.println("Count= "+Count);
}
public void stop()
{
t.stop();
}
}

BIN
java-move_test/baddy.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
java-move_test/ball.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

122
java-move_test/ball.java Normal file
View File

@ -0,0 +1,122 @@
import java.applet.*;
import java.awt.*;
/* I know a ball isn't a Rectangle,
* but Rectangle provides alot of useful methods/properties :) */
class Ball extends Rectangle {
public int xdir,ydir;
public Color color;
public Ball(int size) {
xdir = 0;
ydir = 0;
this.width = size;
this.height = size;
color = Color.black;
}
public void collide(Ball b) {
this.xdir*=-1;
this.ydir*=-1;
b.xdir*=-1;
b.ydir*=-1;
}
public void check(Dimension d) {
Rectangle r = new Rectangle(d.width,d.height);
if (!r.contains(this)) {
if (this.x < 0) this.x = 0;
else if (this.x > r.width-this.width) this.x = r.width-this.width;
if (this.y < 0) this.y = 0;
else if (this.y > r.height-this.height) this.y = r.height-this.height;
if (this.x == 0 || this.x == r.width-this.width) xdir*=-1;
if (this.y == 0 || this.y == r.height-this.height) ydir*=-1;
}
}
public void move() {
this.translate(xdir,ydir);
}
public void paint(Graphics g) {
g.setColor(color);
g.fillOval(this.x,this.y,this.width,this.height);
}
}
public class Bouncy extends Applet implements Runnable {
Ball b[]; // ball for.. bouncing
Dimension d;
int w,h,collide;
Image buffer;
public void init() {
d = getSize();
w = d.width;
h = d.height;
collide = 0;
buffer = createImage(w,h);
// now we have to make the balls with random properties
Color c[] = new Color[] {Color.red,Color.green,Color.blue,Color.cyan,Color.magenta,
Color.black,Color.pink,Color.yellow};
b = new Ball[rand(9)+1]; // at MOST 10 balls
for (int j = 0;j < b.length;j++) {
b[j] = new Ball(rand(20)+10); // diameter is at MOST 30
b[j].x = rand(w-b[j].width); // random x
b[j].y = rand(h-b[j].height); // random y
b[j].xdir = rand(3)+2; // random x direction
b[j].ydir = rand(3)+2; // random y direction
b[j].color = c[rand(c.length-1)]; // random color
}
new Thread(this).start();
}
protected int rand(int r) {
return (int)Math.round(Math.random()*r);
}
public void run() {
// if you don't know about threads,
// this will confuse the snot out of you.
// so read up on threads!!
while (true) {
int j,n;
// now we update each ball position
for (j = 0;j < b.length;j++) {
// make sure the ball is in the applet
b[j].check(d);
// move the ball
b[j].move();
// check for collisions...
for (n = 0;n < b.length;n++) {
if (n != j) { // no need to check current ball
if (b[j].intersects(b[n])) {
collide++;
b[j].collide(b[n]); // adjust x/y directions
// move both balls
b[j].move();
b[n].move();
}
}
}
}
Graphics g = getGraphics();
if (g != null) paint(g); // attempt active rendering
else repaint(); // passive will work if active doesn't
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
break;
}
}
}
public void paint(Graphics g) {
Graphics gfx = buffer.getGraphics();
gfx.setColor(Color.white);
gfx.fillRect(0,0,w,h);
for (int j = 0;j < b.length;j++) {
b[j].paint(gfx);
}
gfx.setColor(Color.black);
FontMetrics f = gfx.getFontMetrics();
gfx.drawString("Balls: "+b.length,10,h-f.getAscent());
String s = "Collisions: "+collide;
gfx.drawString(s,w-(f.stringWidth(s)+10),h-f.getAscent());
gfx.drawRect(0,0,w-1,h-1);
g.drawImage(buffer,0,0,null);
}
public void update(Graphics g) {
paint(g);
}
}

BIN
java-move_test/chicken.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

BIN
java-move_test/dirt.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
java-move_test/hello.class Normal file

Binary file not shown.

19
java-move_test/hello.htm Normal file
View File

@ -0,0 +1,19 @@
<HTML>
<HEAD>
<TITLE>My First Applet</TITLE>
</HEAD>
<BODY>
This is the world's simplest applet.
<P>
<APPLET code="hello.class" width=450 height=350>
</APPLET>
<!-- O'Reilly Footer Begins Here -->
<center>
</center>
<!-- O'Reilly Footer Ends Here -->
</BODY>
</HTML>

153
java-move_test/hello.java Normal file
View File

@ -0,0 +1,153 @@
import java.applet.*; // Don't forget these import statements!
import java.awt.*;
import java.awt.Rectangle;
import java.lang.*;
import java.util.Random;
public class hello extends Applet implements Runnable {
Thread t;
Random generator = new Random();
Image Buffer;
Graphics gBuffer;
// for Baddies
int baddies_number = 30;
int baddies_teams_number = 2;
int baddies_angle[][] = new int[baddies_number][3];
int baddies_size = 10;
Rectangle[] baddies = new Rectangle[baddies_number];
Image dirt = Toolkit.getDefaultToolkit().getImage(getClass().getResource("dirt.jpg"));
public void init() {
Buffer=createImage(size().width,size().height);
gBuffer=Buffer.getGraphics();
for (int i = 0; i < baddies_number; i++){
baddies[i] = new Rectangle(generator.nextInt(size().width - baddies_size), generator.nextInt(size().height - baddies_size), baddies_size, baddies_size);
if (collisiontest(i) == -1){
baddies_angle[i][0] = generator.nextInt(31) - 16;
baddies_angle[i][1] = generator.nextInt(31) - 16;
if (i <= baddies_number/2 - 1) baddies_angle[i][2] = 0;
else baddies_angle[i][2] = 1;
}
else i--;
}
t=new Thread(this);
t.start();
}
public int collisiontest(int currentball_number){
for(int i = 0; i < currentball_number; i++){
if (i != currentball_number && baddies[currentball_number].intersects(baddies[i]) == true) return i;
}
return -1;
}
public void battle(int ball1, int ball2) {
if (ball1 == -1) return;
// balls are same colour
if (baddies_angle[ball1][2] == baddies_angle[ball2][2]){
if (baddies[ball1].width > baddies[ball2].width) {baddies[ball2].width = 0; baddies[ball1].height += 5; baddies[ball1].width += 5;}
if (baddies[ball1].width < baddies[ball2].width) {baddies[ball1].width = 0; baddies[ball2].height += 5; baddies[ball2].width += 5;}
if (baddies[ball1].width == baddies[ball2].width) {baddies_angle[ball1][0] *= -1; baddies_angle[ball1][1] *= -1; baddies_angle[ball2][0] *= -1; baddies_angle[ball2][1] *= -1;}
}
// balls are different colours
else {
if(baddies[ball1].width > baddies[ball2].width) {baddies[ball1].width += 5; baddies[ball1].height += 5; baddies[ball2].width = 0;}
if(baddies[ball2].width > baddies[ball1].width) {baddies[ball2].width += 5; baddies[ball2].height += 5; baddies[ball1].width = 0;} }
if(baddies[ball1].width == baddies[ball2].width) {baddies_angle[ball1][0] *= -1; baddies_angle[ball1][1] *= -1; baddies_angle[ball2][0] *= -1; baddies_angle[ball2][1] *= -1;}
}
public void drawstuff() {
gBuffer.drawImage(dirt, 0, 0, this);
for (int i = 0; i < baddies_number; i++){
if (baddies[i].width != 0){
if (baddies_angle[i][2] == 0) gBuffer.setColor(Color.red);
if (baddies_angle[i][2] == 1) gBuffer.setColor(Color.blue);
gBuffer.fillRect(baddies[i].x,baddies[i].y,baddies[i].width,baddies[i].height);
}
}
}
public void paint(Graphics g) {
drawstuff();
g.drawImage(Buffer,0,0,this);
}
public void update(Graphics g) {
paint(g);
}
public void run(){
while(true)
{
for(int i = 0; i < baddies_number; i++){
if(baddies[i].width != 0){
if(baddies_angle[i][0] > 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x >= size().width - baddies[i].width){
baddies[i].x = size().width - baddies[i].width;
baddies_angle[i][0] *= -1;
}
battle(collisiontest(i), i);
}
if(baddies_angle[i][0] < 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x < 0){
baddies[i].x = 0;
baddies_angle[i][0] *= -1;
}
battle(collisiontest(i), i);
}
if(baddies_angle[i][1] > 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y >= size().height - baddies[i].height){
baddies[i].y = size().height - baddies[i].height;
baddies_angle[i][1] *= -1;
}
battle(collisiontest(i), i);
}
if(baddies_angle[i][1] < 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y < 0){
baddies[i].y = 0;
baddies_angle[i][1] *= -1;
}
battle(collisiontest(i), i);
}
}
}
repaint();
// for(int i = 0; i < baddies_number; i++)
// {if (baddies[i].intersects(chickenpos) == true) return;
// }
try {
t.sleep(300);
}
catch (InterruptedException e) {}
}
}
}

View File

@ -0,0 +1,180 @@
import java.applet.*; // Don't forget these import statements!
import java.awt.*;
import java.awt.Rectangle;
import java.lang.*;
import java.util.Random;
public class hello extends Applet implements Runnable {
Thread t;
Random generator = new Random();
Image Buffer;
Graphics gBuffer;
boolean pressedLeft, pressedRight, pressedUp, pressedDown;
// for Chicken
Rectangle chickenpos = new Rectangle(5,5,25,25);
int boxsize = 25;
// for Baddies
int baddies_number = 5;
int baddies_angle[][] = new int[baddies_number][2];
int baddies_size = 35;
Rectangle[] baddies = new Rectangle[10];
// for Walls
int walls_number = 3;
int walls_size = 75;
Rectangle[] walls = new Rectangle[walls_number];
Rectangle goal = new Rectangle(0,0,40,40);
Image dirt = Toolkit.getDefaultToolkit().getImage(getClass().getResource("dirt.jpg"));
Image chicken = Toolkit.getDefaultToolkit().getImage(getClass().getResource("chicken.gif"));
Image baddyimg = Toolkit.getDefaultToolkit().getImage(getClass().getResource("ball.gif"));
public void init() {
Buffer=createImage(size().width,size().height);
gBuffer=Buffer.getGraphics();
goal.x = generator.nextInt(size().width - 70) + 30;
goal.y = generator.nextInt(size().height - 70) + 30;
for (int i = 0; i < baddies_number; i++){
baddies[i] = new Rectangle(generator.nextInt(size().width - 30 - baddies_size) + 30, generator.nextInt(size().height - 30 - baddies_size) + 30, 35, 35);
baddies_angle[i][0] = generator.nextInt(31) - 16;
baddies_angle[i][1] = generator.nextInt(31) - 16;
}
for (int i = 0; i < walls_number; i++){
walls[i] = new Rectangle(generator.nextInt(size().width), generator.nextInt(size().height), walls_size, walls_size);
if (walls[i].intersects(chickenpos) == true || walls[i].intersects(goal) == true) i--;
}
// for (int i= 0; i < walls_number; i++){
// if (int(generator.nextInt(2)) == 0) walls[i] = new Rectangle(generator.nextInt);
// }
t=new Thread(this);
t.start();
}
public boolean collisiontest(int x, int y){
for(int i = 0; i < walls_number; i++){
if (new Rectangle(x,y,boxsize,boxsize).intersects(walls[i]) == true) return true;
}
return false;
}
public boolean keyDown(Event e, int key) {
if(key==Event.LEFT && chickenpos.x - 5 >= 0 && collisiontest(chickenpos.x - 5, chickenpos.y) != true)
// pressedLeft=true;
chickenpos.x = chickenpos.x - 5;
if(key==Event.RIGHT && chickenpos.x + boxsize + 5 <= size().width && collisiontest(chickenpos.x + 5, chickenpos.y) != true)
// pressedRight=true;
chickenpos.x = chickenpos.x + 5;
if(key==Event.UP && chickenpos.y - 5 >= 0 && collisiontest(chickenpos.x, chickenpos.y - 5) != true)
// pressedUp=true;
chickenpos.y = chickenpos.y - 5;
if(key==Event.DOWN && chickenpos.y + boxsize + 5 <= size().height && collisiontest(chickenpos.x, chickenpos.y + 5) != true)
// pressedDown=true;
chickenpos.y = chickenpos.y + 5;
repaint();
return true;
}
public boolean keyUp(Event e, int key)
{
pressedLeft=pressedRight=pressedUp=pressedDown=false;
repaint();
return true;
}
public void drawstuff() {
gBuffer.drawImage(dirt, 0, 0, this);
gBuffer.setColor(Color.black);
gBuffer.fillRect(goal.x, goal.y, goal.width, goal.height);
gBuffer.setColor(Color.green);
for (int i = 0; i < walls_number; i++){
gBuffer.fillRect(walls[i].x, walls[i].y, walls[i].width, walls[i].height);
}
gBuffer.drawImage(chicken, chickenpos.x, chickenpos.y, this);
for (int i = 0; i < baddies_number; i++){
gBuffer.drawImage(baddyimg, baddies[i].x, baddies[i].y, this);
}
}
public void paint(Graphics g) {
drawstuff();
g.drawImage(Buffer,0,0,this);
}
public void update(Graphics g) {
paint(g);
}
public void run(){
while(true)
{
if (goal.contains(new Rectangle(chickenpos.x,chickenpos.y,chickenpos.width,chickenpos.height))) return;
for(int i = 0; i < baddies_number; i++){
if(baddies_angle[i][0] > 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x >= size().width - baddies_size){
baddies[i].x = size().width - baddies_size;
baddies_angle[i][0] *= -1;
}
}
if(baddies_angle[i][0] < 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x < 0){
baddies[i].x = 0;
baddies_angle[i][0] *= -1;
}
}
if(baddies_angle[i][1] > 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y >= size().height - baddies_size){
baddies[i].y = size().height - baddies_size;
baddies_angle[i][1] *= -1;
}
}
if(baddies_angle[i][1] < 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y < 0){
baddies[i].y = 0;
baddies_angle[i][1] *= -1;
}
}
}
repaint();
for(int i = 0; i < baddies_number; i++)
{if (baddies[i].intersects(chickenpos) == true) return;
}
try {
t.sleep(300);
}
catch (InterruptedException e) {}
}
}
}

45
java/CounterThread.java Normal file
View File

@ -0,0 +1,45 @@
import java.applet.*;
import java.awt.*;
public class CounterThread extends Applet implements Runnable
{
Thread t;
int Count;
public void init()
{
Count=0;
t=new Thread(this);
t.start();
}
public boolean mouseDown(Event e,int x, int y)
{
t.stop();
return true;
}
public void run()
{
while(true)
{
Count++;
repaint();
try {
t.sleep(10);
} catch (InterruptedException e) {}
}
}
public void paint(Graphics g)
{
g.drawString(Integer.toString(Count),10,10);
System.out.println("Count= "+Count);
}
public void stop()
{
t.stop();
}
}

BIN
java/baddy.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
java/ball.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

122
java/ball.java Normal file
View File

@ -0,0 +1,122 @@
import java.applet.*;
import java.awt.*;
/* I know a ball isn't a Rectangle,
* but Rectangle provides alot of useful methods/properties :) */
class Ball extends Rectangle {
public int xdir,ydir;
public Color color;
public Ball(int size) {
xdir = 0;
ydir = 0;
this.width = size;
this.height = size;
color = Color.black;
}
public void collide(Ball b) {
this.xdir*=-1;
this.ydir*=-1;
b.xdir*=-1;
b.ydir*=-1;
}
public void check(Dimension d) {
Rectangle r = new Rectangle(d.width,d.height);
if (!r.contains(this)) {
if (this.x < 0) this.x = 0;
else if (this.x > r.width-this.width) this.x = r.width-this.width;
if (this.y < 0) this.y = 0;
else if (this.y > r.height-this.height) this.y = r.height-this.height;
if (this.x == 0 || this.x == r.width-this.width) xdir*=-1;
if (this.y == 0 || this.y == r.height-this.height) ydir*=-1;
}
}
public void move() {
this.translate(xdir,ydir);
}
public void paint(Graphics g) {
g.setColor(color);
g.fillOval(this.x,this.y,this.width,this.height);
}
}
public class Bouncy extends Applet implements Runnable {
Ball b[]; // ball for.. bouncing
Dimension d;
int w,h,collide;
Image buffer;
public void init() {
d = getSize();
w = d.width;
h = d.height;
collide = 0;
buffer = createImage(w,h);
// now we have to make the balls with random properties
Color c[] = new Color[] {Color.red,Color.green,Color.blue,Color.cyan,Color.magenta,
Color.black,Color.pink,Color.yellow};
b = new Ball[rand(9)+1]; // at MOST 10 balls
for (int j = 0;j < b.length;j++) {
b[j] = new Ball(rand(20)+10); // diameter is at MOST 30
b[j].x = rand(w-b[j].width); // random x
b[j].y = rand(h-b[j].height); // random y
b[j].xdir = rand(3)+2; // random x direction
b[j].ydir = rand(3)+2; // random y direction
b[j].color = c[rand(c.length-1)]; // random color
}
new Thread(this).start();
}
protected int rand(int r) {
return (int)Math.round(Math.random()*r);
}
public void run() {
// if you don't know about threads,
// this will confuse the snot out of you.
// so read up on threads!!
while (true) {
int j,n;
// now we update each ball position
for (j = 0;j < b.length;j++) {
// make sure the ball is in the applet
b[j].check(d);
// move the ball
b[j].move();
// check for collisions...
for (n = 0;n < b.length;n++) {
if (n != j) { // no need to check current ball
if (b[j].intersects(b[n])) {
collide++;
b[j].collide(b[n]); // adjust x/y directions
// move both balls
b[j].move();
b[n].move();
}
}
}
}
Graphics g = getGraphics();
if (g != null) paint(g); // attempt active rendering
else repaint(); // passive will work if active doesn't
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
break;
}
}
}
public void paint(Graphics g) {
Graphics gfx = buffer.getGraphics();
gfx.setColor(Color.white);
gfx.fillRect(0,0,w,h);
for (int j = 0;j < b.length;j++) {
b[j].paint(gfx);
}
gfx.setColor(Color.black);
FontMetrics f = gfx.getFontMetrics();
gfx.drawString("Balls: "+b.length,10,h-f.getAscent());
String s = "Collisions: "+collide;
gfx.drawString(s,w-(f.stringWidth(s)+10),h-f.getAscent());
gfx.drawRect(0,0,w-1,h-1);
g.drawImage(buffer,0,0,null);
}
public void update(Graphics g) {
paint(g);
}
}

BIN
java/chicken.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

BIN
java/dirt.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
java/hello.class Normal file

Binary file not shown.

19
java/hello.htm Normal file
View File

@ -0,0 +1,19 @@
<HTML>
<HEAD>
<TITLE>My First Applet</TITLE>
</HEAD>
<BODY>
This is the world's simplest applet.
<P>
<APPLET code="hello.class" width=450 height=350>
</APPLET>
<!-- O'Reilly Footer Begins Here -->
<center>
</center>
<!-- O'Reilly Footer Ends Here -->
</BODY>
</HTML>

153
java/hello.java Normal file
View File

@ -0,0 +1,153 @@
import java.applet.*; // Don't forget these import statements!
import java.awt.*;
import java.awt.Rectangle;
import java.lang.*;
import java.util.Random;
public class hello extends Applet implements Runnable {
Thread t;
Random generator = new Random();
Image Buffer;
Graphics gBuffer;
// for Baddies
int baddies_number = 30;
int baddies_teams_number = 2;
int baddies_angle[][] = new int[baddies_number][3];
int baddies_size = 10;
Rectangle[] baddies = new Rectangle[baddies_number];
Image dirt = Toolkit.getDefaultToolkit().getImage(getClass().getResource("dirt.jpg"));
public void init() {
Buffer=createImage(size().width,size().height);
gBuffer=Buffer.getGraphics();
for (int i = 0; i < baddies_number; i++){
baddies[i] = new Rectangle(generator.nextInt(size().width - baddies_size), generator.nextInt(size().height - baddies_size), baddies_size, baddies_size);
if (collisiontest(i) == -1){
baddies_angle[i][0] = generator.nextInt(31) - 16;
baddies_angle[i][1] = generator.nextInt(31) - 16;
if (i <= baddies_number/2 - 1) baddies_angle[i][2] = 0;
else baddies_angle[i][2] = 1;
}
else i--;
}
t=new Thread(this);
t.start();
}
public int collisiontest(int currentball_number){
for(int i = 0; i < currentball_number; i++){
if (i != currentball_number && baddies[currentball_number].intersects(baddies[i]) == true) return i;
}
return -1;
}
public void battle(int ball1, int ball2) {
if (ball1 == -1) return;
// balls are same colour
if (baddies_angle[ball1][2] == baddies_angle[ball2][2]){
if (baddies[ball1].width > baddies[ball2].width) {baddies[ball2].width = 0; baddies[ball1].height += 5; baddies[ball1].width += 5;}
if (baddies[ball1].width < baddies[ball2].width) {baddies[ball1].width = 0; baddies[ball2].height += 5; baddies[ball2].width += 5;}
if (baddies[ball1].width == baddies[ball2].width) {baddies_angle[ball1][0] *= -1; baddies_angle[ball1][1] *= -1; baddies_angle[ball2][0] *= -1; baddies_angle[ball2][1] *= -1;}
}
// balls are different colours
else {
if(baddies[ball1].width > baddies[ball2].width) {baddies[ball1].width += 5; baddies[ball1].height += 5; baddies[ball2].width = 0;}
if(baddies[ball2].width > baddies[ball1].width) {baddies[ball2].width += 5; baddies[ball2].height += 5; baddies[ball1].width = 0;} }
if(baddies[ball1].width == baddies[ball2].width) {baddies_angle[ball1][0] *= -1; baddies_angle[ball1][1] *= -1; baddies_angle[ball2][0] *= -1; baddies_angle[ball2][1] *= -1;}
}
public void drawstuff() {
gBuffer.drawImage(dirt, 0, 0, this);
for (int i = 0; i < baddies_number; i++){
if (baddies[i].width != 0){
if (baddies_angle[i][2] == 0) gBuffer.setColor(Color.red);
if (baddies_angle[i][2] == 1) gBuffer.setColor(Color.blue);
gBuffer.fillRect(baddies[i].x,baddies[i].y,baddies[i].width,baddies[i].height);
}
}
}
public void paint(Graphics g) {
drawstuff();
g.drawImage(Buffer,0,0,this);
}
public void update(Graphics g) {
paint(g);
}
public void run(){
while(true)
{
for(int i = 0; i < baddies_number; i++){
if(baddies[i].width != 0){
if(baddies_angle[i][0] > 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x >= size().width - baddies[i].width){
baddies[i].x = size().width - baddies[i].width;
baddies_angle[i][0] *= -1;
}
battle(collisiontest(i), i);
}
if(baddies_angle[i][0] < 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x < 0){
baddies[i].x = 0;
baddies_angle[i][0] *= -1;
}
battle(collisiontest(i), i);
}
if(baddies_angle[i][1] > 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y >= size().height - baddies[i].height){
baddies[i].y = size().height - baddies[i].height;
baddies_angle[i][1] *= -1;
}
battle(collisiontest(i), i);
}
if(baddies_angle[i][1] < 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y < 0){
baddies[i].y = 0;
baddies_angle[i][1] *= -1;
}
battle(collisiontest(i), i);
}
}
}
repaint();
// for(int i = 0; i < baddies_number; i++)
// {if (baddies[i].intersects(chickenpos) == true) return;
// }
try {
t.sleep(300);
}
catch (InterruptedException e) {}
}
}
}

180
java/old.hello.java Normal file
View File

@ -0,0 +1,180 @@
import java.applet.*; // Don't forget these import statements!
import java.awt.*;
import java.awt.Rectangle;
import java.lang.*;
import java.util.Random;
public class hello extends Applet implements Runnable {
Thread t;
Random generator = new Random();
Image Buffer;
Graphics gBuffer;
boolean pressedLeft, pressedRight, pressedUp, pressedDown;
// for Chicken
Rectangle chickenpos = new Rectangle(5,5,25,25);
int boxsize = 25;
// for Baddies
int baddies_number = 5;
int baddies_angle[][] = new int[baddies_number][2];
int baddies_size = 35;
Rectangle[] baddies = new Rectangle[10];
// for Walls
int walls_number = 3;
int walls_size = 75;
Rectangle[] walls = new Rectangle[walls_number];
Rectangle goal = new Rectangle(0,0,40,40);
Image dirt = Toolkit.getDefaultToolkit().getImage(getClass().getResource("dirt.jpg"));
Image chicken = Toolkit.getDefaultToolkit().getImage(getClass().getResource("chicken.gif"));
Image baddyimg = Toolkit.getDefaultToolkit().getImage(getClass().getResource("ball.gif"));
public void init() {
Buffer=createImage(size().width,size().height);
gBuffer=Buffer.getGraphics();
goal.x = generator.nextInt(size().width - 70) + 30;
goal.y = generator.nextInt(size().height - 70) + 30;
for (int i = 0; i < baddies_number; i++){
baddies[i] = new Rectangle(generator.nextInt(size().width - 30 - baddies_size) + 30, generator.nextInt(size().height - 30 - baddies_size) + 30, 35, 35);
baddies_angle[i][0] = generator.nextInt(31) - 16;
baddies_angle[i][1] = generator.nextInt(31) - 16;
}
for (int i = 0; i < walls_number; i++){
walls[i] = new Rectangle(generator.nextInt(size().width), generator.nextInt(size().height), walls_size, walls_size);
if (walls[i].intersects(chickenpos) == true || walls[i].intersects(goal) == true) i--;
}
// for (int i= 0; i < walls_number; i++){
// if (int(generator.nextInt(2)) == 0) walls[i] = new Rectangle(generator.nextInt);
// }
t=new Thread(this);
t.start();
}
public boolean collisiontest(int x, int y){
for(int i = 0; i < walls_number; i++){
if (new Rectangle(x,y,boxsize,boxsize).intersects(walls[i]) == true) return true;
}
return false;
}
public boolean keyDown(Event e, int key) {
if(key==Event.LEFT && chickenpos.x - 5 >= 0 && collisiontest(chickenpos.x - 5, chickenpos.y) != true)
// pressedLeft=true;
chickenpos.x = chickenpos.x - 5;
if(key==Event.RIGHT && chickenpos.x + boxsize + 5 <= size().width && collisiontest(chickenpos.x + 5, chickenpos.y) != true)
// pressedRight=true;
chickenpos.x = chickenpos.x + 5;
if(key==Event.UP && chickenpos.y - 5 >= 0 && collisiontest(chickenpos.x, chickenpos.y - 5) != true)
// pressedUp=true;
chickenpos.y = chickenpos.y - 5;
if(key==Event.DOWN && chickenpos.y + boxsize + 5 <= size().height && collisiontest(chickenpos.x, chickenpos.y + 5) != true)
// pressedDown=true;
chickenpos.y = chickenpos.y + 5;
repaint();
return true;
}
public boolean keyUp(Event e, int key)
{
pressedLeft=pressedRight=pressedUp=pressedDown=false;
repaint();
return true;
}
public void drawstuff() {
gBuffer.drawImage(dirt, 0, 0, this);
gBuffer.setColor(Color.black);
gBuffer.fillRect(goal.x, goal.y, goal.width, goal.height);
gBuffer.setColor(Color.green);
for (int i = 0; i < walls_number; i++){
gBuffer.fillRect(walls[i].x, walls[i].y, walls[i].width, walls[i].height);
}
gBuffer.drawImage(chicken, chickenpos.x, chickenpos.y, this);
for (int i = 0; i < baddies_number; i++){
gBuffer.drawImage(baddyimg, baddies[i].x, baddies[i].y, this);
}
}
public void paint(Graphics g) {
drawstuff();
g.drawImage(Buffer,0,0,this);
}
public void update(Graphics g) {
paint(g);
}
public void run(){
while(true)
{
if (goal.contains(new Rectangle(chickenpos.x,chickenpos.y,chickenpos.width,chickenpos.height))) return;
for(int i = 0; i < baddies_number; i++){
if(baddies_angle[i][0] > 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x >= size().width - baddies_size){
baddies[i].x = size().width - baddies_size;
baddies_angle[i][0] *= -1;
}
}
if(baddies_angle[i][0] < 0) {baddies[i].x += baddies_angle[i][0];
if (baddies[i].x < 0){
baddies[i].x = 0;
baddies_angle[i][0] *= -1;
}
}
if(baddies_angle[i][1] > 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y >= size().height - baddies_size){
baddies[i].y = size().height - baddies_size;
baddies_angle[i][1] *= -1;
}
}
if(baddies_angle[i][1] < 0) {baddies[i].y += baddies_angle[i][1];
if (baddies[i].y < 0){
baddies[i].y = 0;
baddies_angle[i][1] *= -1;
}
}
}
repaint();
for(int i = 0; i < baddies_number; i++)
{if (baddies[i].intersects(chickenpos) == true) return;
}
try {
t.sleep(300);
}
catch (InterruptedException e) {}
}
}
}

106
js/nabi-kitaakabane.html Normal file
View File

@ -0,0 +1,106 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size=+1>
<p>&nbsp;</p>
<p align=center>北赤羽駅出発ナビ \(^o^)/</p>
<script type="text/javascript">
function pad2(number){
return (number < 10 ? '0' : '') + number;
}
var walking_delay = 2;
var weekdays = [
[05,13],[05,22],[05,34],[05,42],[05,50],
[06,00],[06,07],[06,14],[06,19],[06,29],[06,34],[06,39],[06,45],[06,52],[06,59],
[07,03],[07,07],[07,11],[07,18],[07,23],[07,30],[07,34],[07,38],[07,44],[07,48],[07,51],[07,54],
[08,00],[08,06],[08,09],[08,16],[08,20],[08,24],[08,30],[08,36],[08,39],[08,50],
[09,03],[09,12],[09,17],[09,23],[09,36],[09,42],[09,55],
[10,03],[10,16],[10,25],[10,37],[10,54],
[11,02],[11,14],[11,24],[11,40],[11,54],
[12,14],[12,24],[12,34],[12,54],
[13,04],[13,14],[13,34],[13,40],[13,54],
[14,14],[14,24],[14,34],[14,54],
[15,04],[15,14],[15,34],[15,40],[15,54],
[16,13],[16,22],[16,34],[16,39],[16,53],[16,59],
[17,04],[17,12],[17,17],[17,28],[17,37],[17,47],[17,52],[17,57],
[18,08],[18,17],[18,27],[18,34],[18,46],[18,51],[18,57],
[19,07],[19,12],[19,18],[19,31],[19,37],[19,47],[19,52],[19,57],
[20,06],[20,12],[20,22],[20,28],[20,35],[20,47],[20,58],
[21,06],[21,15],[21,28],[21,34],[21,40],[21,47],[21,53],
[22,09],[22,16],[22,23],[22,33],[22,46],
[23,03],[23,12],[23,22],[23,33],[23,46],
[24,08],
];
var weekends = [
[05,13],[05,22],[05,33],[05,49],
[06,00],[06,08],[06,20],[06,36],[06,43],[06,51],
[07,02],[07,09],[07,16],[07,22],[07,33],[07,39],[07,45],[07,56],
[08,01],[08,13],[08,23],[08,33],[08,43],[08,56],
[09,04],[09,16],[09,25],[09,36],[09,43],[09,54],
[10,03],[10,15],[10,23],[10,34],[10,44],[10,54],
[11,04],[11,14],[11,24],[11,34],[11,40],[11,54],
[12,04],[12,14],[12,24],[12,34],[12,54],
[13,05],[13,14],[13,34],[13,40],[13,54],
[14,14],[14,24],[14,34],[14,54],
[15,04],[15,14],[15,34],[15,40],[15,54],
[16,13],[16,23],[16,35],[16,43],[16,54],
[17,00],[17,05],[17,15],[17,23],[17,34],[17,39],[17,53],[17,57],
[18,03],[18,15],[18,24],[18,34],[18,44],[18,55],
[19,03],[19,16],[19,23],[19,36],[19,43],[19,56],
[20,03],[20,15],[20,21],[20,36],[20,44],[20,51],
[21,06],[21,18],[21,40],[21,48],
[22,05],[22,26],[22,42],
[23,01],[23,23],[23,46],
[24,08],
];
var d = new Date();
var curr_day = d.getDay();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
var curr = (curr_hour * 60) + curr_min;
var curr_plus_5 = curr + walking_delay;
var hits = 0;
if(curr_day != 0 && curr_day != 6){
document.write("<u>Weekdays</u><br>");
for(i=0 ; i<weekdays.length; i++){
curr_train = (weekdays[i][0]*60) + weekdays[i][1];
if( curr_train >= curr_plus_5 )
{
document.write( pad2(weekdays[i][0]), ":", pad2(weekdays[i][1]),
" (", curr_train - curr, "分後)",
"<br>");
hits++;
};
if(hits == 4)
{break;}
}
hits = 0;
}
document.write("<br><u>Weekends / Holidays</u><br>");
for(i=0 ; i<weekends.length; i++){
curr_train = (weekends[i][0]*60) + weekends[i][1];
if( curr_train >= curr_plus_5 )
{
document.write( pad2(weekends[i][0]), ":", pad2(weekends[i][1]),
" (", curr_train - curr, "分後)",
"<br>");
hits++;
};
if(hits == 4)
{break;}
}
</script>
</font>
</body>
</html>

7
local_rsync.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
SRCROOT=/home/kairu0
DSTROOT=/myPL/Backups
RSYNC=/usr/bin/rsync
${RSYNC} -rl ${SRCROOT} ${DSTROOT}
# ${RSYNC} -rl --ignore-existing ${SRCROOT} ${DSTROOT}

18
mpg123.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
mpg123 -C \
http://ice.somafm.com/secretagent \
http://ice.somafm.com/illstreet \
http://ice.somafm.com/groovesalad \
http://ice.somafm.com/lush \
http://ice.somafm.com/indiepop \
http://ice.somafm.com/bootliquor \
http://ice.somafm.com/suburbsofgoa \
http://ice.somafm.com/digitalis \
http://ice.somafm.com/covers \
http://ice.somafm.com/tags \
http://ice.somafm.com/poptron \
http://ice.somafm.com/beatblender \
http://ice.somafm.com/sonicuniverse \
http://ice.somafm.com/dronezone \
http://ice.somafm.com/cliqhop \
http://ice.somafm.com/spacestation

28
parse-images.cgi Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/perl
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTML::LinkExtor; # allows you to extract the links off of an HTML page.
$URL = $ARGV[0];
$browser = LWP::UserAgent->new();
$browser->timeout(10);
my $request = HTTP::Request->new(GET => $URL);
my $response = $browser->request($request);
if ($response->is_error()) {printf "%s\n", $response->status_line;}
$contents = $response->content();
my ($page_parser) = HTML::LinkExtor->new(undef, $URL);
$page_parser->parse($contents)->eof;
@links = $page_parser->links;
foreach $link (@links) {
if($$link[2] =~ /jpg$/){
print '<br><img src="'.$$link[2].'"></br>'."\n";
}
}

View File

@ -0,0 +1,28 @@
#!/usr/bin/perl
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTML::LinkExtor; # allows you to extract the links off of an HTML page.
$URL = $ARGV[0];
$browser = LWP::UserAgent->new();
$browser->timeout(10);
my $request = HTTP::Request->new(GET => $URL);
my $response = $browser->request($request);
if ($response->is_error()) {printf "%s\n", $response->status_line;}
$contents = $response->content();
my ($page_parser) = HTML::LinkExtor->new(undef, $URL);
$page_parser->parse($contents)->eof;
@links = $page_parser->links;
foreach $link (@links) {
if($$link[2] =~ /jpg$/){
print '<br><img src="'.$$link[2].'"></br>'."\n";
}
}

16
photosort.pl Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/perl
use v5.14;
my $binidentify = '/usr/bin/identify';
for my $file (<*.jpg>){
my $cmd = sprintf "%s -format '%[exif:DateTime]' %s", $binidentify, $file;
my $outty = `$cmd`;
next if ($? != 0);
next if ($outty !~ m/^(\d{4})\:(\d{2})\:(\d{2})/);
my ($year, $month, $day) = ($1, $2, $3);
my $cmd = sprintf "mkdir -p %s/%s", $year, $month;
`$cmd`;
my $cmd = sprintf "mv %s %s/%s/", $file, $year, $month;
`$cmd`;
}

4
rotate-video.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/sh
AVCONVBIN=/usr/bin/avconv
${AVCONVBIN} -vf "transpose=1" -vf "scale=480:-1" -i $1 $2

27
ssc_mount.sh Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/expect -f
set timeout -1
set dest_ip "203.215.131.224"
set dest_user "sburdick"
set tc_exe "/cygdrive/c/Program\\ Files/TrueCrypt/TrueCrypt.exe"
set tc_vol "c:\\Users\\sburdick\\personal_backup.tc"
set tc_vol_pass "jRqH4YsZpqwxTKULiYWqtoNz"
set dest_drv_ltr "Q"
set action [lindex $argv 0]
if { $action=="mount" || $action=="unmount" } {
spawn ssh $dest_user@$dest_ip
expect "$ "
# try to unmount the TC volume just in case (with /s to silently die if not actually mounted)
send "$tc_exe /d Q /q /s\r"
expect "$ "
if { $action=="mount" } {
# mount the TC volume
send "$tc_exe /v \"$tc_vol\" /q /p $tc_vol_pass /l Q\r"
expect "$ "
}
}
exit
#REFERENCE:
# /cygdrive/c/Program\ Files/TrueCrypt/TrueCrypt.exe /v "c:\Users\sburdick\personal_backup.tc" /q /p jRqH4YsZpqwxTKULiYWqtoNz /l Q
# /cygdrive/c/Program\ Files/TrueCrypt/TrueCrypt.exe /d Q /q

9
ssc_rsync.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
DIRS=( '/home/kairu0/Documents' '/home/kairu0/Pictures' '/home/kairu0/kairu0.tc' )
ELEMENTS=${#DIRS[@]}
for (( i=0;i<$ELEMENTS;i++)); do
rsync -r ${DIRS[${i}]} sburdick@203.215.131.224:/cygdrive/q
done
#Reference:
# rsync -r /home/kairu0/Pictures sburdick@203.215.131.224:/cygdrive/q

2
sync-to-knowing.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
rsync -avz --group=media --chmod=ug+rw,o-rwx /home/kairu0/Pictures/album/ knowing:/home/media/Pictures/album

14
systemd/sshesame.service Normal file
View File

@ -0,0 +1,14 @@
[Unit]
Description=SSH Honeypot
After=network.target
[Service]
Type=simple
#ExecStartPre=/sbin/setcap 'cap_net_bind_service=+ep' /home/honeypot/go/bin/sshesame
ExecStartPre=/sbin/setcap 'cap_net_bind_service=+ep' /home/honeypot/go/bin/sshesame
ExecStart=/bin/su - honeypot -c "/home/honeypot/go/bin/sshesame -listen_address 192.168.0.131 -port 22 -host_key /home/honeypot/poopsalot"
#User=honeypot
#Group=honeypot
[Install]
WantedBy=multi-user.target

14
wallpaper_changer.py Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/python
import os, os.path, random, gconf
startdir="/home/kairu/Pictures/wtf"
gkey="/desktop/gnome/background/picture_filename"
imgs=[]
for root, dirs, files in os.walk(startdir):
for file in files:
base, ext = os.path.splitext(file)
if ext.lower() in [".jpg", ".png", ".svg"]:
imgs.append(os.path.join(root, file))
img = random.choice(imgs)
gconf.client_get_default().set_string(gkey, img)