Skip to content

Instantly share code, notes, and snippets.

View alterisian's full-sized avatar

Ian Moss alterisian

View GitHub Profile
@alterisian
alterisian / gist:fbeea6fe45895acdbc29ce786f433ad9
Created September 3, 2025 11:27
What if instead of just git init, we added all the files, and an initial commit, and created the repo on github?
#!/bin/bash
set -e
project_name=$(basename "$PWD")
git init
git add .
git commit -m "initial commit of $project_name"
gh repo create "$project_name" --private --source=. --remote=origin --push
@alterisian
alterisian / gist:9acfdf2d14b5f4cbcab84b13933d8891
Created January 20, 2025 16:56
first rails 8.0.1 install, errors.
WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
stringio (>= 0)
Available/installed versions of this gem:
- 3.1.2
- 3.0.4
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.
run bundle lock --add-platform=x86_64-linux
Writing lockfile to /home/oceanician/code/montes/malagamontes/Gemfile.lock
run bundle binstubs bundler
@alterisian
alterisian / json_keys.rb
Created May 8, 2024 14:50
Got a massive blob of JSON? Got your rails console or irb open? Past in this method, and get a summary of the keys in the JSON!
# usage: json_keys(json_data, mode: 'summary')
def json_keys(data, mode: 'summary', depth: 0)
indent = ' ' * depth # Indentation based on the nesting level
case data
when Array
json_keys(data.first, mode: mode, depth: depth + 1) if data.any?
when Hash
data.each do |key, value|
@alterisian
alterisian / es.sh
Created May 4, 2023 14:46
A shell script that will run the passed in command every 25 (DELAY_TIME) seconds.
#!/bin/bash
# check if parameter is passed
if [ -z "$1" ]; then
echo "Usage: $0 <command>"
exit 1
fi
# set the delay time (in seconds)
DELAY_TIME=25
# A probably flawed benchmark. Interested in your 2.6.3 vs TruffleRuby vs 3.0 times though :)
# Usage: open irb. paste in the below function.
def press
puts "Ruby version: #{RUBY_VERSION}, patchlevel: #{RUBY_PATCHLEVEL}, platform: #{RUBY_PLATFORM}, release date: #{RUBY_RELEASE_DATE}"
count=0
start = Time.now
(1..10000).each { |value| count=count+value }; puts count
finish = Time.now
(finish - start)
class Car
attr_accessor driving_genome
#Car has_many driving_methods
#Car has_many driving_evaluation_methods
#Car has_many detection_methods
def initiliaze(param)
@driving_genome = param.to_a
end
rails g model user name:string
rails g model favorite name:string design_id:integer user_id:integer
rails g model design name:string
class User
has_many: favourites
end
class Favorite
@alterisian
alterisian / extract_li_data.js
Created December 19, 2017 16:12
artoo dom example
// Ok. What am I trying to do?
// ===========================
// Extract 3 data values from the li elements in a ul list,
// that are easily identified by classes on the target page.
// Not rocket science.
// Tool: Aartoo. Client Side Javascript. Looks evolved.
// Simple bookmarket run from the extraction page,
@alterisian
alterisian / survival_panther.rb
Created March 19, 2015 20:57
survival_panther.rb
class Panther < RTanque::Bot::Brain
NAME = 'Survival Panther'
include RTanque::Bot::BrainHelper
def tick!
command.radar_heading = sensors.radar_heading + (RTanque::Heading::ONE_DEGREE * 30)
at_tick_interval(25) do
print_stats
end
@alterisian
alterisian / gitlg.bash
Created June 16, 2014 09:32
Give Git Log a nicer alias under git lg
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"