Skip to content

Instantly share code, notes, and snippets.

@5c0tt
5c0tt / rand.php
Created November 22, 2023 03:36
Random number distribution test
<?php
$randomIntegers = array_fill(1, 10, 0);
for ($i = 0; $i < 1000; $i++) {
$randomInt = rand(1, 10);
$randomIntegers[$randomInt]++;
}
$j = 0;
foreach ($randomIntegers as $number) {
@5c0tt
5c0tt / gist:5feb84d9485131c958de
Created September 16, 2015 11:29
Rotating Folder Backup Script
#!/bin/bash
# Taken from http://triq.net/script/rotating-folder-backup-script
# because the site is slow and down, and I wanted to review this later
# Originally created by zany on Tue, 03/17/2009 - 13:38
BASEDIR=/home/projects # SET THIS
BAKDIR=/home/backups # SET THIS
stamp=$(date +%Y-%m-%d)
@5c0tt
5c0tt / cc-validate
Created May 20, 2015 02:31
How to validate a credit card
<<
testUnit = [
["5303271788938868", "Mastercard"],
["5172130074420403", "Mastercard"],
["5528046926304929", "Mastercard"],
["5123524378572523", "Mastercard"],
["5570030393432659", "Mastercard"],
["5207435393545197", "Mastercard"],
["5251165104558727", "Mastercard"],
@5c0tt
5c0tt / trim-to-launchbar
Created May 20, 2015 02:29
Use tr.im as a url shortner for LaunchBar
-- Use tr.im as a url shortner for LaunchBar
-- http://twitter.com/cometbus
-- 01:17:55 PM [05/31/2009]
-- Initial script
-- 02:01:19 PM [05/31/2009]
-- Added in truncateString() function
-- Added in urlencodetext() function
@5c0tt
5c0tt / growl.as
Created May 20, 2015 02:18
Register and activate your code with Growl on Mac OS X using AppleScript
--Simple growl notification function. Will register as well as display a message with growl
-- 03/19/2010 Scott Haneda <scott@newgeo.com>
--
-- Sample Usage: growlMessage("Title of growl window", "Body message → of growl window", "Give a Name", "Name of App for icon")
-- The last argument is for an icon, you can use the name of any installed application, with or without the .app extension
using terms from application "AppleScript Utility"
on growlMessage(growl_notification_title, growl_notification_body, growl_app_name, growl_icon)
tell application "AppleScript Utility"
-- growl_notification_title, The title in the actual growl window
@5c0tt
5c0tt / evernote-backup=sort-of.txt
Last active August 29, 2015 14:19
Backup Evernote on Macintosh
-- Copy and paste all the code below into your Script Editor and run it as you see fit
-- PURPOSE: Export all notes in Evernote to an ENEX file so that
-- the notes can be backed up to an external drive or to the cloud
-- Change the path below to the location you want the notes to be exported
set filename to (do shell script "date '+%Y-%m-%d-%H.%M.%S'") & (".export.enex")
-- Get the path the Application Support and then append the backup folder
set e to path to application support from user domain
set p to POSIX path of e & "Evernote-Backups/"
#!/bin/bash
# 01/31/15 - 06:12:06 A.M.
echo -e "\ndrops-size is shell script that scans Dropbox and finds files I have shared that
are too large and need to be looked at for potential deletion\n\n"
# Variables that are used often enough to need setting them, yup, cool comment
# Directory where we are scanning files
DEST=/Users/$USER/Dropbox/Public/drops
SIZE="+250k" # The size as defined in the find man page, getting all files larger…
TEMP="/tmp/drops-output.txt"
#!/bin/bash
/Applications/Arq.app/Contents/MacOS/Arq backupnow&
echo 'Arq is backing up now.'
# Toss the application backup trigger into the background.
# Somehow, this will run via a keystroke triggering app without root access, which to backup your
# entire comptuer, you are going to need root access to backup any system files
# Perhaps I am remembering incorrectly and I was only backing up ~/
# Though even still, there are a few root owned ( Intentionally created and placed under certain strict chown:chmod)
# running this will create the file in whatever directory your terminal is in.
# A newly opened Terminal will create a file in your ~/home directory. If you already
# have a Terminal open type 'cd' and press return, that will bring you to your home directory.
dd if=/dev/random of=LargeFileForScott.img bs=1024 count=0 seek=$[1024*1000]
# Or we can force it on your Desktop:
dd if=/dev/random of=~/Desktop/LargeFileForScott.img bs=1024 count=0 seek=$[1024*1000]
@5c0tt
5c0tt / backup-tm-now
Created January 3, 2015 08:05
Backup Time Machine Now
This script will make Time Machine perform an incremental backup as if you were
to either let it run on schedule or select the menulet from the menu bar.
------------ Type `man tmutil` for all the options ------------ This should be
run as root to work corrcty, which will make it much harder to run from a
launcher or from a keyboard launcher, as they are not directy set up to accept
user input.
Below is the `readme.md` that I made to go with these files, though it is
probebly no longer needed given this is so simple I am merely making a `gist`