Skip to content

Instantly share code, notes, and snippets.

View rush2sk8's full-sized avatar
🤔
why is this a thing 🤔

Rushad rush2sk8

🤔
why is this a thing 🤔
View GitHub Profile
@rush2sk8
rush2sk8 / deep_values.rb
Created August 16, 2019 18:53
gets all values from a hash no matter how nester
def deep_values(h, acc = [])
return [nil] if h.nil?
case h
when Hash
return deep_values(h.values)
when Array
acc.push(*h.map { |v| deep_values(v) })
else
acc.push(h)
end
@rush2sk8
rush2sk8 / removevmware.sh
Last active April 29, 2019 17:06
script to remove vmware fusion from MacOS
#!/usr/bin/env bash
remove() {
entry="$1"
echo -ne "Removing $entry ["
sudo rm -rf "$entry"
if [[ ! -e "$entry" ]]; then
echo -ne "OK"
else
require 'pdf-reader'
wordsToFind = ARGV
Dir.entries(".").select { |f| File.file?(File.join(".", f)) && File.extname(f) == ".pdf"}.each { |file|
puts file
pReader = PDF::Reader.new(file)
require 'open-uri'
def download_image(url, dest)
open(url) do |u|
File.open(dest, "wb") { |f| f.write(u.read)}
end
end
@rush2sk8
rush2sk8 / scrapeimage.rb
Last active February 5, 2019 01:16
given a file with image urls itll download them to a directory of that filename
require 'open-uri'
def download_image(url, dest)
open(url) do |u|
File.open(dest, "wb") { |f| f.write(u.read)}
end
end
files = []