Skip to content

Instantly share code, notes, and snippets.

View virtualstaticvoid's full-sized avatar

Chris Stefano virtualstaticvoid

View GitHub Profile
@virtualstaticvoid
virtualstaticvoid / default.tint2rc
Last active November 12, 2020 16:09
Tint2 Configuration
# Tint2 config file
# Generated by tintwizard (http://code.google.com/p/tintwizard/)
# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure
# Background definitions
# ID 1
rounded = 3
border_width = 0
#background_color = #000000 60
background_color = #000000 80
@virtualstaticvoid
virtualstaticvoid / .r-version
Last active July 22, 2020 04:52
Heroku Buildpack R - plumber Example
3.4.3
@virtualstaticvoid
virtualstaticvoid / shell
Created July 8, 2020 16:22
Get Docker Container IP Address
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container
@virtualstaticvoid
virtualstaticvoid / install-ca-certificate
Created July 2, 2020 10:35
Install Custom CA Certificate (with name check)
#!/bin/bash
cert=${1:-ca.pem}
name=$2
sudo mkdir -p /usr/local/share/ca-certificates
sudo cp $cert /usr/local/share/ca-certificates/
sudo update-ca-certificates
@virtualstaticvoid
virtualstaticvoid / active_relation_extensions.rb
Last active May 22, 2019 17:51
A better `find_each` and `find_in_batches` for ActiveRecord, which preserves the original order of the query
module ActiveRelationExtensions
def find_each_with_order(options = {})
find_in_batches_with_order(options) do |records|
records.each { |record| yield record }
end
end
# NOTE: any limit() on the query is overridden with the batch size
def find_in_batches_with_order(options = {})
@virtualstaticvoid
virtualstaticvoid / Aptfile
Last active February 11, 2019 10:10
Heroku Buildpack R - RPostgreSQL Example
libcurl4-openssl-dev
libpq-dev
@virtualstaticvoid
virtualstaticvoid / spec_helper.rb
Last active November 14, 2018 20:22 — forked from pauljamesrussell/spec_helper.rb
RSpec Matchers
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
model.send("#{association}").clear

why ./task.js?

One word: task automation. It's basically zero effort and you can use the ./task.js package manager to handle any repetitive tasks. You can use ./task.js to automate everything with minimum effort.

./task.js provides the structure, order, and authority that you as a developer so desperately crave. ./task.js will also take responsibility for your actions if you need it to. It's what everybody is using now. ./task.js is the new hotness. It's all about ./task.js now, just like that.

This is compared to npm run/bash scripts, which are:

@virtualstaticvoid
virtualstaticvoid / lambda_coalesce.rb
Last active November 14, 2018 20:21
Ruby Lambda Coalesce
#
# Given a bit of program logic:
#
# x2 = y1 * x1 || y2 / exchange_rate || x2 * exchange_rate / y1 || another
#
# Where y1, x1, y2 and x2 are function calls, which may yield nils
#
def coalesce(*args)
@virtualstaticvoid
virtualstaticvoid / Ensure.cs
Last active November 14, 2018 20:19
C# Ensure for Argument Errors
//
// MIT License
// Copyright (c) 2009 Chris Stefano <virtualstaticvoid@gmail.com>
//
using System;
using System.Diagnostics;
internal static class Ensure
{
[DebuggerStepThrough]