Skip to content

Instantly share code, notes, and snippets.

@Melraidin
Melraidin / fix-ruby-libcrypto.sh
Created June 27, 2021 02:52
Fix issue with unsafe libcrypto loading: "WARNING: /Users/myuser/.rvm/rubies/ruby-2.6.3/bin/ruby is loading libcrypto in an unsafe way"
ln -s /usr/local/Cellar/openssl@1.1/1.1.1k/lib/libcrypto.dylib /usr/local/lib/libcrypto.dylib
ln -s /usr/local/Cellar/openssl@1.1/1.1.1k/lib/libssl.dylib /usr/local/lib/libssl.dylib
@ykpythemind
ykpythemind / test.yml
Last active January 27, 2024 09:30
GitHub Action + Rails test example
# .github/workflows/test.yml
name: test
on: [push]
env:
RUBY_VERSION: 2.7.2
NODE_VERSION: 14.15.5
RAILS_ENV: test
@boddhisattva
boddhisattva / setup_system_tests_with_rspec_devise_rails6.md
Last active November 9, 2023 20:58
Setup System tests to work with RSpec, Devise and Rails 6

Setting this up took quite a bit of time and research for me, so just thought of sharing the learnings along the way that led to a working setup.

  • Initial error that I was getting with running System tests in Rails 6

    System test integration requires Rails >= 5.1 and has a hard dependency on a webserver and `capybara`, please add capybara to your Gemfile and configure a webserver (e.g. `Capybara.server = :webrick`) before attempting to use system tests.
    • since the error above says specify Capybara in the Gemfile, a part of my Gemfile looked like below:
@seachai
seachai / gist:948ed1eeafa32ce03db6685edb879f71
Last active May 8, 2024 11:03
iTerm 2 Natural Text Editing Preset
On iTerm2 - Open Preferences > Profiles > Keys > Key Mappings > Presets > Select Natural Text Editing
- You can move a word backwards using Option ⌥ + ← and a word forwards using Option ⌥ + →
- Move to the start of the line using fn + ← and to the end of the line with fn + →.
- Also you can delete a word backwards using Option ⌥ + ⌫, delete the whole line using Command ⌘ + ⌫.
If the preset doesn't appear, reinstall iTerm2. If you installed it using Homebrew + Cask:
brew cask reinstall iterm2
@dannguyen
dannguyen / shakespeare-ngrams-cli-ack.md
Last active May 30, 2023 16:04
How to tokenize and create n-grams in Shakespeare from the command-line

Creating Shakespearean n-grams with just the command-line and regexes

This is a quick example showing how to use regexes to find tri-grams in Shakespeare...well, 570,872 of them, anyway, if we do some basic filtering of non-dialogue.

Though tokenization and n-grams should typically be done using a proper natural language processing framework, it's possible to do in a jiffy from the command-line, using standard Unix tools and ack, the better-than-grep utility.

What are n-grams?

@ata4
ata4 / moviebarcode.py
Last active July 24, 2023 16:02
Python 3 script to create movie barcodes with ffmpeg and imagemagick
#!/usr/bin/python
import sys, subprocess, getopt, os, json
def main(argv):
script_name = os.path.basename(argv[0])
try:
opts, args = getopt.getopt(argv[1:], "sw:h:q:", ["help", "solid-color", "width=", "height=", "samples="])
except getopt.GetoptError as err:
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@tam7t
tam7t / gist:86eb4793e8ecf3f55037
Last active April 14, 2022 10:57
Securing Ruby's OpenSSL

Are your Ruby HTTPS API calls secure?

Let's check:

2.0.0-p481 :001 > OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
 => {:ssl_version=>"SSLv23", :verify_mode=>1, :ciphers=>"ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", :options=>-2147482625}
2.0.0-p481 :002 > rating = JSON.parse(RestClient::Resource.new("https://www.howsmyssl.com/a/check" ).get)['rating']
 => "Bad"
@TakahikoKawasaki
TakahikoKawasaki / sinatra+thin+ssl.rb
Last active October 19, 2023 14:38
Sinatra + Thin + SSL
#!/usr/bin/env ruby
#
# This code snippet shows how to enable SSL in Sinatra+Thin.
#
require 'sinatra'
require 'thin'
class MyThinBackend < ::Thin::Backends::TcpServer
def initialize(host, port, options)
@sprice
sprice / airbnb_core_values.md
Last active September 23, 2019 01:58
Airbnb Core Values

source: https://vimeo.com/59958555

  1. Host
  2. Champion the Mission
  3. Every Frame Matters
  4. Be a cereal entrepreneur [1]
  5. Simplify
  6. Embrace the adventure

[1] Airbnb bootstrapped themselves by selling Obama and McCain branded cereal at the 2008 Democratic National Convention. https://www.airbnb.ca/obamaos