Skip to content

Instantly share code, notes, and snippets.

@gjtorikian
gjtorikian / remove_file.rb
Last active March 20, 2023 03:21
How to remove a file from a subdirectory using the GitHub API v3
#!/usr/bin/env ruby
require 'octokit'
# !!! DO NOT EVER USE HARD-CODED VALUES IN A REAL APP !!!
login = ENV['GH_LOGIN']
password = ENV['GH_LOGIN_PASSWORD']
repo = "gjtorikian/crud-test"
master = client.ref(repo, "heads/master")
@gjtorikian
gjtorikian / main.go
Created October 13, 2020 15:43
Heroku chat sample
package main
import (
"encoding/json"
"io"
"log"
"net/http"
"os"
"github.com/go-redis/redis"

Check out the YouTube link for additional help: https://youtu.be/MoZtlB06yys

  1. Go to https://vax4nyc.nyc.gov/patient/s/vaccination-schedule
  2. Fill out all your personal details
  3. Copy this script above
  4. In your browser, open up Developer Tools
  5. Paste this script into the console
  6. Sit back and wait for an appointment you like to appear. This usually takes about ten minutes.

If the page stops refreshing (because it found an appointment), but you don't like the time or location, just type:

@gjtorikian
gjtorikian / pro-up.rb
Last active January 7, 2021 17:01
Is there new info on MacRumors yet
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
model = 'MacBook_Pro_16'
url = "https://buyersguide.macrumors.com/\##{model}"
doc = Nokogiri::HTML(URI.open(url))
@gjtorikian
gjtorikian / homepage_spec.rb
Last active December 5, 2019 20:28
Basic Capybara testing with Jekyll + Rack
require 'spec_helper'
describe "Homepage" do
before :each do
visit "/index.html"
end
it "has a title" do
expect(page).to have_css("h1", text: "GitHub Help")
@gjtorikian
gjtorikian / querying_for_files.graphql
Last active February 22, 2019 14:24
sample GQL query for fetching files via GitHub GQL API
{
# get a list of files off the tree entries
repository(owner: "gjtorikian", name: "html-proofer") {
ref(qualifiedName: "refs/heads/master") {
target {
... on Commit {
tree {
entries {
object {
__typename
@gjtorikian
gjtorikian / lunrjs_worker.js
Created January 9, 2015 00:14
Jekyll LunrJS worker
importScripts('/assets/vendor/lunr.js/lunr.min.js');
// create lunr.js search index specifying that we want to index the title and body fields of documents.
var lunr_index = lunr(function() {
this.field('title', { boost: 10 });
this.field('body');
this.ref('id');
}),
entries;
@gjtorikian
gjtorikian / extract.rb
Last active May 27, 2018 17:43
Geocities extraction script
require 'pty'
def run_cmd(cmd)
begin
PTY.spawn( cmd ) do |stdout, stdin, pid|
begin
# Do stuff with the output here. Just printing to show it works
stdout.each { |line| print line }
rescue Errno::EIO
puts "Errno:EIO error, but this probably just means " +
{
repository(owner: "facebook", name: "mention-bot") {
object(expression: "master") {
... on Commit {
blame(path: "cookieJar.js") {
ranges {
startingLine
endingLine
age
commit {
@gjtorikian
gjtorikian / routes.rake
Created March 15, 2016 02:44
Rake task to show Sinatra routes within a Rails app
namespace :api do
# Sample output is a header (listing the class name) followed by
# the verb + endpoint. For example:
#
# ### Within Api::Git
#
# GET /repositories/:repository_id/git
desc "List all the API endpoints with their verbs."
task :routes => :environment do