Skip to content

Instantly share code, notes, and snippets.

Nate Berkopec nateberkopec

View GitHub Profile
# Assumes you have a DIGITALOCEAN_TOKEN env var pre-set
# Assumes you have terraform and mutagen installed
# Assumes DO has an SSH key uploaded
DO_REGION="sgp1" # Set to DO region:
SSH_KEY_FINGERPRINT="your-key-fingerprint" # You can find this in your control panel
if [ -z $DIGITALOCEAN_TOKEN ]; then
exit 1
View gist:7b573f2438ff768aafd2d785deb60817
ruby-install truffleruby
>>> Installing truffleruby 19.3.0 into /Users/nateberkopec/.rubies/truffleruby-19.3.0 ...
>>> Installing dependencies for truffleruby 19.3.0 ...
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from a1939cfe7 to a4d7bb64a.
Updated 3 taps (shopify/shopify, homebrew/core and homebrew/cask).
==> New Formulae
libtorch onnxruntime tio vale
==> Updated Formulae
cd ~
mv git-completion.bash .git-completion.bash
source ~/.git-completion.bash
echo "source ~/.git-completion.bash" >> ~/.bash_profile
nateberkopec / thread.diff
Created Feb 14, 2019
thread quantum patch
View thread.diff
diff --git a/thread_pthread.c b/thread_pthread.c
index d8d3184c62..4e28b9a31d 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -175,7 +175,7 @@ static const void *const condattr_monotonic = NULL;
/* 100ms. 10ms is too small for user level thread scheduling
* on recent Linux (tested on 2.6.35)
-#define TIME_QUANTUM_MSEC (100)
+#define TIME_QUANTUM_MSEC (10)
nateberkopec /
Last active Jul 23, 2020
A Simple Correction

In yesterday's post I said, in relation to "how does .present? work on ActiveRecord::Relation", I said that present? performs an existence check SELECT 1 AS one FROM ... LIMIT 1 because it calls exists? underneath. This is actually wrong - it loads the relation.

Jonathan Mast corrected me on Twitter. It turns out, I should have paid closer attention! Here is the actual implementation of blank? on ActiveRecord::Relation on Rails master:

# Returns true if relation is blank.
def blank?
View presenttest.rb
ActiveRecord::Base.logger =
MODEL = User # enter a model that exists in your app here
users = MODEL.all
puts "users.present?"
users = nil
users = MODEL.all
puts "users.empty?"
nateberkopec / hide_or_display_index.js
Last active Dec 3, 2018
Hide gmail inbox when empty, v0.1
View hide_or_display_index.js
// ==UserScript==
// @name Gmail Inbox Empty Reward
// @namespace
// @version 0.2
// @description Hides much of the Gmail UI when your inbox is empty, to give you a little reward for reaching Inbox Zero!
// @author Nate Berkopec
// @include*
// @include*
// @include http://**
// @include https://**
nateberkopec / repro_script.rb
Created Aug 14, 2017
Sentry repro script for rails
View repro_script.rb
# frozen_string_literal: true
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
gemfile(true) do
nateberkopec / resume.txt
Created Aug 7, 2017
Mohammed Elias Al-Hussein - Resume
View resume.txt
Mohammed Elias Alhussein
Istanbul , Turkey
+ 90 5312303185
Gender : Male | Date of birth 1/1/1993 | Nationality Syrian
2015 - 2016 Member of a software Developer Team
View console.rb
require 'krpc'
CLIENT_NAME = "Console"
HOST_IP = ""
$client = CLIENT_NAME, host: HOST_IP).connect!
You can’t perform that action at this time.