Skip to content

Instantly share code, notes, and snippets.

View coding-chimp's full-sized avatar

Bastian Bartmann coding-chimp

View GitHub Profile
@coding-chimp
coding-chimp / 82467.geojson
Last active May 26, 2021 10:17
Building large GraphQL response is slow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "aws-sdk-s3"
gem "benchmark-ips"
end
S3_BUCKET_NAME=""
@coding-chimp
coding-chimp / hltb.rb
Created May 28, 2020 14:10
Scrape HowLongToBeat.com
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "http"
gem "nokogiri"
end
url = "https://howlongtobeat.com/search_results"
@coding-chimp
coding-chimp / pull_request_stats.rb
Created March 19, 2019 20:43
Get the authors and reviewers of the last 100 PRs of a repository.
require "graphql/client"
require "graphql/client/http"
API_TOKEN = "<TOKEN>"
HTTP = GraphQL::Client::HTTP.new("https://api.github.com/graphql") do
def headers(context)
{ "Authorization": "bearer #{API_TOKEN}" }
end
end
@coding-chimp
coding-chimp / arp.rb
Created October 10, 2015 15:05
Scan network
HOST_REGEX = /(\d+.\d+.\d+.\d+)\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)\s(.*)/
result = `sudo arp-scan -l`
hosts = result.scan(HOST_REGEX)
hosts.each do |host|
puts host.to_s
end
@coding-chimp
coding-chimp / answer.rb
Last active August 29, 2015 13:56
Testing implementation of methods in direct subclasses
# This part is pretty much optional. The same error would be raised if we wouldn't define the
# method here, but I would definitely put something here to signal other what methods are
# needed in the subclasses. Just doing it with comments would be feasible, too.
class Answer < ActiveRecord::Base
def label
raise NoMethodError, %(undefined method "label" for ##{self.class.name})
end
end
@coding-chimp
coding-chimp / excel2csv.rb
Last active January 3, 2016 20:49
Convert XLS to Shopify CSV
# encoding: UTF-8
#!/usr/bin/env ruby
require 'rubygems'
require 'roo'
# Original script: https://github.com/scpike/excel2csv
USAGE = <<END
Convert an excel file to csv via the roo library
@coding-chimp
coding-chimp / barchart.rb
Last active December 28, 2015 03:49 — forked from ttscoff/barchart.rb
#!/usr/bin/env ruby
# encoding: utf-8
# Brett Terpstra 2013, WTF license <http://www.wtfpl.net/txt/copying/>
# Outputs a vertical bar chart from date-based JSON data
# Requires the JSON rubygem: `[sudo] gem install json`
require 'date'
require 'open-uri'
require 'rubygems'
require 'json'
@coding-chimp
coding-chimp / release_bt_keyboard.sh
Last active December 27, 2015 06:49 — forked from hughsaunders/release_bt_keyboard.sh
Steal bluetooth keyboard and trackpad from iMac in TDM and release them to it.
#!/usr/bin/env bash
# disable local bluetooth
blueutil off
# enable imac's bluetooth
ssh [email protected] '/usr/local/bin/blueutil on'
@coding-chimp
coding-chimp / duration.rb
Created June 6, 2013 13:02
Easy way to get the duration in seconds of one or multiple audio files.
#!/usr/bin/env ruby
require 'rubygems'
require 'audioinfo'
if ARGV.size >=1
ARGV.each do |path|
length = AudioInfo.open(path) { |info| info.length }
puts File.basename(path) + ": #{length}"
end