Skip to content

Instantly share code, notes, and snippets.

View theprogramsam's full-sized avatar

Sam theprogramsam

View GitHub Profile
@theprogramsam
theprogramsam / capybara_fill_stripe_elements.rb
Created March 4, 2025 04:12 — forked from iloveitaly/capybara_fill_stripe_elements.rb
Fill in a Stripe Elements (https://stripe.com/docs/elements) credit card field using capybara
def fill_stripe_elements(card)
using_wait_time(15) { within_frame('stripeField_card_element0') do
card.to_s.chars.each do |piece|
find_field('cardnumber').send_keys(piece)
end
find_field('exp-date').send_keys("0122")
find_field('cvc').send_keys '123'
find_field('postal').send_keys '19335'
end }
@theprogramsam
theprogramsam / sign-pdf.rb
Created January 27, 2025 17:09 — forked from matiaskorhonen/sign-pdf.rb
Quick and dirty PDF signing in Ruby (using Origami)
#!/usr/bin/env ruby
require "openssl"
require "time"
begin
require "origami"
rescue LoadError
abort "origami not installed: gem install origami"
end
@theprogramsam
theprogramsam / rfc3161.txt
Created January 13, 2025 18:10 — forked from Manouchehri/rfc3161.txt
List of free rfc3161 servers.
https://rfc3161.ai.moda
https://rfc3161.ai.moda/adobe
https://rfc3161.ai.moda/microsoft
https://rfc3161.ai.moda/apple
https://rfc3161.ai.moda/any
http://rfc3161.ai.moda
http://timestamp.digicert.com
http://timestamp.globalsign.com/tsa/r6advanced1
http://rfc3161timestamp.globalsign.com/advanced
http://timestamp.sectigo.com
@theprogramsam
theprogramsam / rails_sql_case_example.rb
Created January 10, 2021 00:00 — forked from zoltan-nz/rails_sql_case_example.rb
UPDATE more record with one query using CASE sql statement in Ruby on Rails. In this example update sort_order integer based on the sort order of products.
#List of product ids in sorted order. Get from jqueryui sortable plugin.
#product_ids = [3,1,2,4,7,6,5]
#product_ids.each_with_index do |id, index|
# Product.where(id: id).update_all(sort_order: index+1)
#end
##CASE syntax example:
##Product.where(id: product_ids).update_all("sort_order = CASE id WHEN 539 THEN 1 WHEN 540 THEN 2 WHEN 542 THEN 3 END")
@theprogramsam
theprogramsam / MySQL_5-7_macOS.md
Created December 16, 2019 04:15 — forked from robhrt7/MySQL_5-7_macOS.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
@theprogramsam
theprogramsam / Debounce.coffee
Created July 27, 2019 02:21 — forked from lmartins/Debounce.coffee
Debounce function execution in CoffeeScript
# Based on:
# http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
debounce = (func, threshold, execAsap) ->
timeout = null
(args...) ->
obj = this
delayed = ->
func.apply(obj, args) unless execAsap
timeout = null
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
//const cssPath = 'https://raw.githubusercontent.com/mallowigi/slack-one-dark-theme/master/custom.css';
const cssPath = 'https://gist.githubusercontent.com/samholst/ffbfd26165d8ff9304aa99887bcae445/raw/cda7d818fb2c1fd252aa0ce0a55274331852e99c/slack_dark_theme.css';
let cssPromise = fetch(cssPath).then(response => response.text());
@theprogramsam
theprogramsam / slack_dark_theme.css
Created June 2, 2019 01:59
Custom css for slack dark theme copied from mallowigi
@import url("https://fonts.googleapis.com/css?family=Bad+Script|Rajdhani");
:root {
/* Modify these to change your theme colors: */
--primary: #E5C17C;
--accent: #568AF2;
--text: #ABB2BF;
--background: #282C34;
--background-elevated: #3B4048;
/* These should be less important: */
--background-hover: #525964;
@theprogramsam
theprogramsam / ghost_methods.md
Created May 9, 2019 23:46 — forked from bnbry/ghost_methods.md
ruby 'ghost' methods

Ruby 'Ghost' Methods

Ghosts are spooooky!

But really this is just a goofy name for one of many options of dynamically creating methods in ruby which is part of that fancy business known as Metaprogramming. Which is a fancy name for the concept of writing code that 'writes' code. It's bananas and great and the best thing you will ever see in your career also it is terrible, horrible, no good and the worst thing you will ever see in your career. We are just going to go over what has been dubbed 'ghost' methods by someone who likes to have cool names for things, there is a lot more to metaprogramming in general than just this technique but it is a pretty good entry point.

@theprogramsam
theprogramsam / postgres-brew.md
Created March 15, 2019 22:52 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update