Skip to content

Instantly share code, notes, and snippets.

Nate Berkopec nateberkopec

View GitHub Profile
View tf-dev-script.sh
#!/bin/bash
# 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: https://www.digitalocean.com/docs/platform/availability-matrix/
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
View git-autocomplete.sh
cd ~
wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
mv git-completion.bash .git-completion.bash
source ~/.git-completion.bash
echo "source ~/.git-completion.bash" >> ~/.bash_profile
@nateberkopec
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
nateberkopec / correction.md
Last active Jul 23, 2020
A Simple Correction
View correction.md

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?
  records.blank?
end
View presenttest.rb
ActiveRecord::Base.logger = Logger.new(STDOUT)
MODEL = User # enter a model that exists in your app here
users = MODEL.all
puts "users.present?"
users.present?
users = nil
users = MODEL.all
puts "users.empty?"
@nateberkopec
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 http://tampermonkey.net/
// @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 http://mail.google.com/*
// @include https://mail.google.com/*
// @include http://*.mail.google.com/*
// @include https://*.mail.google.com/*
@nateberkopec
nateberkopec / repro_script.rb
Created Aug 14, 2017
Sentry repro script for rails
View repro_script.rb
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
@nateberkopec
nateberkopec / resume.txt
Created Aug 7, 2017
Mohammed Elias Al-Hussein - Resume
View resume.txt
____________________________________________________________
PERSONAL INFORMATION
Mohammed Elias Alhussein
Istanbul , Turkey
+ 90 5312303185
eliass.alhusain@gmail.com
Gender : Male | Date of birth 1/1/1993 | Nationality Syrian
WORK EXPERIENCE
2015 - 2016 Member of a software Developer Team
View console.rb
require 'krpc'
CLIENT_NAME = "Console"
HOST_IP = "192.168.1.13"
$client = KRPC::Client.new(name: CLIENT_NAME, host: HOST_IP).connect!
binding.pry
You can’t perform that action at this time.