Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
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
@nateberkopec
nateberkopec / git-autocomplete.sh
Created October 3, 2019 16:32
git auto completion
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 February 14, 2019 20:28
thread quantum patch
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 June 6, 2025 19:24
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?
  records.blank?
end
@nateberkopec
nateberkopec / presenttest.rb
Created January 11, 2019 14:31
present test
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 December 3, 2018 14:49
Hide gmail inbox when empty, v0.1
// ==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 August 14, 2017 15:51
Sentry repro script for rails
# 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 August 7, 2017 18:17
Mohammed Elias Al-Hussein - Resume
____________________________________________________________
PERSONAL INFORMATION
Mohammed Elias Alhussein
Istanbul , Turkey
+ 90 5312303185
[email protected]
Gender : Male | Date of birth 1/1/1993 | Nationality Syrian
WORK EXPERIENCE
2015 - 2016 Member of a software Developer Team
require 'krpc'
CLIENT_NAME = "Console"
HOST_IP = "192.168.1.13"
$client = KRPC::Client.new(name: CLIENT_NAME, host: HOST_IP).connect!
binding.pry
@nateberkopec
nateberkopec / test.rb
Created July 31, 2017 01:08
KRPC - test rocket script
require 'krpc'
CLIENT_NAME = "Flight Computer"
MISSION_NAME = "UPPER STAGE TEST"
HOST_IP = "192.168.1.13"
KRPC_CMD_WAIT = 0.01
SPOOL_TO_THRUST_PERCENT = 0.25
$client = KRPC::Client.new(name: CLIENT_NAME, host: HOST_IP).connect!