Skip to content

Instantly share code, notes, and snippets.

View tansengming's full-sized avatar
🏠
Working from home

SengMing Tan tansengming

🏠
Working from home
View GitHub Profile
@mri-dula
mri-dula / convert_to_active_storage.rb
Last active February 27, 2021 00:14
Create active storage attachment records from paperclip files in PostgreSQL
class ConvertToActiveStorage < ActiveRecord::Migration[5.2]
require 'open-uri'
def change
active_storage_blob_statement = ActiveRecord::Base.connection.raw_connection.prepare('active_storage_blob_statement', <<-SQL)
INSERT INTO active_storage_blobs (
"key", filename, content_type, metadata, byte_size, checksum, created_at
) VALUES ($1, $2, $3, '{}', $4, $5, $6)
SQL
@nettofarah
nettofarah / newrelic_instrumenter.rb
Created March 13, 2017 21:46
sample newrelic instrumenter for graphql-ruby
# NewRelic instrumenter for GraphQL-ruby
#
# In your controller:
# ::NewRelic::Agent.add_custom_attributes({
# user_id: @user.try(:id),
# query_string: @query_string,
# query_arguments: @query_variables
# })
#
# @document = self.class.trace_execution_scoped(["GraphQL#parse"]) do

Code Review

A consolidation of advice and stuff from the internet

What is code review?

Code review one person reading over another's code and offering comments, suggestions, and feedback about how it could be improved. Often this is done at companies or in open source projects as a required step before proposed changes can be merged into a

@kentbrew
kentbrew / pinmarklet.md
Last active April 9, 2024 18:34
How to recreate your long-lost Pinterest bookmarklet.

How to recreate your long-lost Pinterest bookmarklet.

Right-click your bookmarks bar and choose Add Page (Chrome) or New Bookmarklet (Firefox).

In Name, put this:

Pin It

In URL, put this:

@jdmaturen
jdmaturen / company-ownership.md
Last active July 29, 2023 22:39
Who pays when startup employees keep their equity?

Who pays when startup employees keep their equity?

JD Maturen, 2016/07/05, San Francisco, CA

As has been much discussed, stock options as used today are not a practical or reliable way of compensating employees of fast growing startups. With an often high strike price, a large tax burden on execution due to AMT, and a 90 day execution window after leaving the company many share options are left unexecuted.

There have been a variety of proposed modifications to how equity is distributed to address these issues for individual employees. However, there hasn't been much discussion of how these modifications will change overall ownership dynamics of startups. In this post we'll dive into the situation as it stands today where there is very near 100% equity loss when employees leave companies pre-exit and then we'll look at what would happen if there were instead a 0% loss rate.

What we'll see is that employees gain nearly 3-fold, while both founders and investors – particularly early investors – get dilute

@jguice
jguice / Rakefile.tmPreferences
Created May 16, 2015 16:58
Rakefile preferences (Textmate/Sublime Text) that will add rake tasks to the symbol list
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Symbol List</string>
<key>scope</key>
<string>source.ruby.rakefile.task</string>
<key>settings</key>
<dict>
@mlgill
mlgill / uninstall_adobe_air.sh
Last active May 3, 2021 02:00
Uninstalling Adobe AIR on Mac OS X
#!/bin/sh
# Installing Adobe AIR creates an application called "Adobe AIR Uninstaller" in /Applications/Utilities.
# Unfortunately, running this application does not uninstall the application and instead, it seems to
# unhelpfully confirm that it's installed (http://twitter.com/modernscientist/status/495388916267384833/photo/1).
# The proper way to run this application as an uninstaller is to run the enclosed from the command line
# with the flag "-uninstall" as superuser:
sudo /Applications/Utilities/Adobe\ AIR\ Uninstaller.app/Contents/MacOS/Adobe\ AIR\ Installer -uninstall
@wearhere
wearhere / shell.swift
Last active March 5, 2021 01:29
Shell scripting in Swift, using a proper hashbang and a custom subshell operator.
#!/usr/bin/xcrun swift -i -sdk /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
//
// shell.swift
//
// Shell scripting in Swift, using a proper hashbang and a custom subshell operator.
// To run: `chmod +x shell.swift && ./shell.swift`.
//
// If you edit this in Xcode, ignore the error on the hashbang line.
// To play around with this in a playground, comment out the hashbang line.
//
@JonRowe
JonRowe / db_spec_helper.rb
Last active August 29, 2015 13:57
Delay the slow things!
# An example used to segregate DB loading to those specs requiring it only.
RSpec.configure do |config|
config.include DBHelper::DB, db: true
config.include DSL::Setup, db: true
config.before(:all, db: true) do
DBHelper.load!
end
@kouky
kouky / sublime-text-2-key-bindings
Created September 25, 2013 23:41
My Sublime Text 2 Key Bindings, created with the help of the awesome @benhoskings
[
{ "keys": ["super+shift+e"], "command": "use_selection_for_replace"},
{ "keys": ["alt+g"], "command": "next_result"},
{ "keys": ["super+v"], "command": "paste_and_indent"},
{ "keys": ["shift+super+v"], "command": "paste"},
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["super+alt+f"], "command": "replace_next"},
{ "keys": ["super+ctrl+r"], "command": "reveal_in_side_bar"},