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
class RubyClass | |
attr_accessor :name, :size # Creates getter and setter methods. | |
@@class_variable = 0 | |
# constructor | |
def initialize(name, size) | |
@name = name | |
@size = size | |
@@class_variable += 1 |
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
var map = [ | |
[1, 1, 1], | |
[-1, -1, -1], | |
[0, 0, 0] | |
]; | |
function checkStatus(team){ | |
// Check vertical wins | |
for (var i = 0; i < 3; i++) { | |
if (map[i][0] == team && map[i][1] == team && map[i][2] == team) { |
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
# Parse android picture filenames to get the creation time and set the mtime of the file | |
# Example: 20180721_230439.jpg's mtime will be set to 2018-07-21 23:04:39 -0400 | |
require 'date' | |
require "FileUtils" | |
dir = ARGV[0] | |
def get_mtime_from_filepath(path) | |
filename = File.basename(path, ".*") |
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
# Only compares file names, not the file contents | |
dir1 = ARGV[0] | |
dir2 = ARGV[1] | |
def get_relative_path_of_contents(dir) | |
return Dir["#{dir}/**/*"].select{|f| File.file?(f)}.map { |e| | |
e[dir] = "" | |
e | |
} |
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 download_temp_file(url, file_path) | |
temp_folder = Dir.tmpdir() | |
temp_file_path = "#{temp_folder}/#{File.basename(file_path)}" | |
File.open(temp_file_path, "wb") do |file| | |
file.write open(url).read | |
end | |
return temp_file_path | |
end |
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
raspistill -q 100 -t 1 -ss 6000000 -sh 0 -co 50 -br 50 -sa 0 -ev +2 -ex night -awb auto -ISO 800 -mm average -n -o "/media/OSXSUNNY/timelapse/singleshot/$(date +"%Y-%m-%d_%H%M%S").jpg" |
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
if pidof -x "abc.sh" >/dev/null; then | |
echo "Process already running" | |
fi |
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/sh | |
WIDTH=1920 | |
HEIGHT=1080 | |
NUM_FRAMES=$1 | |
FRAME_INTERVAL=$2 | |
DIR=$3 | |
DATE=$(date +"%Y-%m-%d_%H%M%S") | |
if [ ! -n "$DIR" ]; then |
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
require "JSON" | |
require 'net/http' | |
require 'uri' | |
def open(url) | |
Net::HTTP.get(URI.parse(url)) | |
end | |
# Put in your own latitude and longitude | |
puts JSON.parse(open('http://api.sunrise-sunset.org/json?lat=45.4215000&lng=-75.6972000&formatted=0&date=today'))["results"]["sunrise"] |
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/sh | |
WIDTH=1920 | |
HEIGHT=1080 | |
DIR="~/" | |
mkdir -p $DIR | |
FILE_NAME="${DIR}$(date +"%Y-%m-%d_%H%M%S").jpg" |
NewerOlder