Skip to content

Instantly share code, notes, and snippets.

View schmijos's full-sized avatar

Josua Schmid schmijos

View GitHub Profile
@jasonrdsouza
jasonrdsouza / pocket_exporter.py
Last active January 31, 2024 19:13
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 July 4, 2023 12:07
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
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;
@schneems
schneems / asset_sync_is_the_devil.md
Last active June 19, 2021 00:12
I hate asset_sync

A not politically correct assertion of my feelings towards a piece of software:

Note: Repetition builds cynicism, asset_sync isn't bad, but when an asset problem cannot be solved via support it gets escalated to me. Often times someone using asset_sync the problem is due to their use of the library and not from Heroku.

Backstory

The asset sync gem uploads your assets (images, css, javascript) to S3. From there you can either point browsers to the copy on S3 or use a CDN + the S3 bucket. It's a good idea, and solved a problem at one time.

It is no longer needed and you should now use https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn instead. So rather than copying your assets over to S3 after they are precompiled the CDN grabs them from your website instead. Here's some reasons why it's better.

@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active May 24, 2024 01:23
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@atrepca
atrepca / gist:7159195
Last active December 4, 2023 21:28
Send Heroku logs to an rsyslog server and save them to separate files by application
  • Add a Heroku drain for your app to forward the logs to your rsyslog server:

      heroku drains:add --app my-prod-app syslog://logging01.prod.mydomain.net:514
    
  • List the drain you just created to get the unique Drain ID:

      heroku drains -x --app my-prod-app
    
  • On the rsyslog server save the logs coming from Heroku to separate files, without duplicating to /var/log/messages (thanks to the & ~). Create a /etc/rsyslog.d/90-heroku.conf file containing:

      if $HOSTNAME startswith 'Drain_ID' then /opt/log/heroku/my-prod-app.log
    

& ~