Skip to content

Instantly share code, notes, and snippets.

View schmijos's full-sized avatar

Josua Schmid schmijos

View GitHub Profile
@yatsu
yatsu / rbenv-ruby187-macos.sh
Last active July 13, 2023 19:36
Install ruby-1.8.7 with rbenv on macOS Catalina (10.15)
#!/bin/sh
# 1) Install Xcode 11
# 2) Install command line tools: `xcode-select --install`
# 3) Install HomeBrew
# 4) brew tap cartr/qt4 && brew install cartr/qt4/[email protected] subversion rbenv
# 5) Setup rbenv
# 6) Run this command
PKG_CONFIG_PATH="$(brew --prefix cartr/qt4/[email protected])/lib/pkgconfig" \
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@bennyfactor
bennyfactor / Ruby 1.8.7 ree-187 macOS Catalina 10.15.7.sh
Last active February 23, 2023 05:18
How to rebuild old ruby on modern macos, because of course the headers moved and bundler suddenly can't build native extensions any more
# This is based on https://gist.github.com/whitehat101/87c06c29dabfe15f094ec331b77a7c6d and https://solitum.net/openssl-os-x-el-capitan-and-brew/
# I take no responsibility for the damage it may do to any other build system you run.
# Disable system integrity protection before this mess.
# Uninstall everything critical to get back to baseline
rbenv uninstall ree-1.8.7-2012.02
@lopezjurip
lopezjurip / script.sh
Created September 25, 2016 02:08
Github full code review
# Create empty branch.
git checkout --orphan review
git rm -rf .
git commit --allow-empty -m "Create empty branch"
git push --set-upstream origin review
# Create `project` branch from `master` current state.
git checkout -b project
git merge master --allow-unrelated-histories
git push --set-upstream origin project
@jasonrdsouza
jasonrdsouza / pocket_exporter.py
Last active September 10, 2024 19:55
Export archived article data from Pocket
'''This script can be used to export data from Pocket (getpocket.com)
Uses include migrating to a different "read it later" service, saving
specific articles to another service, backing up your reading history,
and more.
Currently it can be used to export links and metadata for archived
articles with a given tag, which are more recent than a given timestamp.
An example use case is to export all articles you have tagged as
"to-export", which are newer than 10 days old. The timestamp functionality
@grosscol
grosscol / rubobadcop_spec.rb
Created September 4, 2015 19:54
Rubocop & Rspec headache with testing a module
# I either end up with a rubocop error or an rspec error. In each case, the travis build will not pass.
# Rubocop error:
# RSpec/DescribedClass: Use described_class instead of Hydra::Works::GenericFile::Characterization
describe Hydra::Works::GenericFile::Characterization do
let(:demo_class) do
Class.new(Hydra::Works::GenericFile::Base) do
include Hydra::Works::GenericFile::Characterization
end
end
# Wouldn't it be great if you could have STI like functionality
# without needing to encode strings of class names in the database?
# Well today is your lucky day! Discriminable Model is here to help.
#
# Simply specify your models desired type column, and provide a block to
# do the discrimination. If you want the whole STI-esque shebang of properly
# typed finder methods you can supply an array of 'discriminate_types' that will
# be used to apply an appropriate type.
#
# class MyModel < ActiveRecord::Base
@Pathoschild
Pathoschild / google-sheets-color-preview.js
Last active August 1, 2024 21:43
A Google Sheets script which adds color preview to cells. When you edit a cell containing a valid CSS hexadecimal color code (like #000 or #000000), the background color is changed to that color and the font color is changed to the inverse color for readability.
/*
This script is meant to be used with a Google Sheets spreadsheet. When you edit a cell containing a
valid CSS hexadecimal color code (like #000 or #000000), the background color will change to that
color and the font color will be changed to the inverse color for readability.
To use this script in a Google Sheets spreadsheet:
1. go to Tools » Script Editor;
2. replace everyting in the text editor with this code;
3. click File » Save;
@victor-homyakov
victor-homyakov / find-big-files-not-in-head.rb
Created February 20, 2015 09:24
Find big files in git history that don't exist in head. Usage: `ruby find-big-files-not-in-head.rb [size in MB] [rev]`
#!/usr/bin/env ruby -w
treshold, head = ARGV
head ||= 'HEAD'
Megabyte = 1000 ** 2
treshold = (treshold || 0.1).to_f * Megabyte
big_files = {}
commit_number = 0
commits_count = 0
@wojtha
wojtha / fake_stripe_server.rb
Last active September 28, 2016 22:06
Fake Stripe mock backend server for generating tokens for stripe.js
#!/usr/bin/env ruby
require 'sinatra/base'
require 'json'
require 'stripe_mock'
# Mount fake Sinatra Stripe Server to Capybara
#
# Example:
#
# feature 'Subscribe' do