Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
@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!
@nateberkopec
nateberkopec / mohammed-signed.md
Last active August 8, 2017 13:40
mohammed-signed.md

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256


layout: post title: "How To Get A Computer Science Degree in a Warzone" date: 2017-08-10 7:00:00 summary: "An appeal to any Canadian readers or friends of mine to help one of our own: a young computer programmer fleeing the Syrian Civil War." readtime: "2580 words/12 minutes"


@nateberkopec
nateberkopec / keybase.md
Created July 29, 2017 17:32
keybase.md

Keybase proof

I hereby claim:

  • I am nateberkopec on github.
  • I am nateberkopec (https://keybase.io/nateberkopec) on keybase.
  • I have a public key ASCNxGGomrAYwaFCor0xa9ATHG3YaMR_K8r_22uBOVfAwgo

To claim this, I am signing this object:

@nateberkopec
nateberkopec / .block
Created July 14, 2017 21:26 — forked from mbostock/.block
Force-Directed Graph
license: gpl-3.0
height: 600