Skip to content

Instantly share code, notes, and snippets.

View kenn's full-sized avatar

Kenn Ejima kenn

View GitHub Profile
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@justjanne
justjanne / Price Breakdown.md
Last active April 11, 2024 22:21 — forked from kylemanna/price.txt
Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/Online.net:

Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/Online.net:

Permalink: git.io/vps

$5/mo

Provider Type RAM Cores Storage Transfer Network Price
@jugyo
jugyo / mysql2spatial.rb
Created October 26, 2016 14:12
A patch for spatial data support for rails's mysql2 adapter, only support `point` geometry data
require 'geo_ruby/ewk'
# NOTE: Set SRID 0 as same as mysql's default
GeoRuby::SimpleFeatures::DEFAULT_SRID = 0
module ActiveRecord
module Type
class Spatial < Value
def type
:spatial
@derwiki
derwiki / README.md
Last active September 27, 2023 17:50
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

Email customers for: Successful payments - Disabled AND Receipt_email set : No receipts sent (Would send receipt in Live mode)
Email customers for: Successful payments - Disabled AND Receipt_email not set : No receipts sent — Enable customer receipts
Email customers for: Successful payments - Disabled AND Receipt_email not set BUT Customer email set : No receipts sent — Enable customer receipts
Email customers for: Successful payments - Enabled AND Receipt_email set : No receipts sent (Would send receipt in Live mode)
Email customers for: Successful payments - Enabled AND Receipt_email not set : No receipts sent — No email address for this payment
Email customers for: Successful payments - Enabled AND Receipt_email not set BUT Customer email set : No receipts sent (Would send receipt in Live mode)
@pixeltrix
pixeltrix / time_vs_datatime.md
Last active February 18, 2024 19:20
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@drblue
drblue / fix_onedrive.sh
Last active April 16, 2024 21:54
Fix OneDrive for Mac CPU usage
#!/bin/bash
## Fix OneDrive for Mac CPU usage
##
## Seems this is still a problem 5 years later after I created this little gist.
## I have long since stopped using OneDrive (luckily), but according to
## comments below, I have added the new path for OfficeFileCache for macOS
## Mojave (10.14) and Catalina (10.15).
## Run this on macOS Mojave (10.14) and Catalina (10.15)
find ~/Library/Containers/ -type d -name OfficeFileCache -exec rm -r {} +
@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active October 6, 2022 12:47
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@gbuesing
gbuesing / ml-ruby.md
Last active February 28, 2024 15:13
Resources for Machine Learning in Ruby

UPDATE a fork of this gist has been used as a starting point for a community-maintained "awesome" list: machine-learning-with-ruby Please look here for the most up-to-date info!

Resources for Machine Learning in Ruby

Gems

@jashkenas
jashkenas / semantic-pedantic.md
Last active November 29, 2023 14:49
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil