Skip to content

Instantly share code, notes, and snippets.

View scottcreynolds's full-sized avatar

Scott C Reynolds scottcreynolds

View GitHub Profile
@theodorosploumis
theodorosploumis / Nework_throttling_profiles.md
Last active May 21, 2025 21:41
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active June 30, 2025 03:36
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for(...;...;...) or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@mankind
mankind / rails-jsonb-queries
Last active May 3, 2025 05:37
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module TemplateTest
class Application < Rails::Application
@J-Scag
J-Scag / bash dice roller
Last active December 18, 2021 19:31
A dice roller made in bash because I wanted to be able to roll dice in my terminal and wanted to try out bash scripting. Bash scripting kind of sucks. (UPDATED: fixed minor formatting issue in the roll spread)
# A function to do roll dice because I'm screwing around in bash
function roll() {
# capture parameter
declare -i DIE_COUNT=$1
declare -i DIE_SIDES=$2
declare -i BONUS=$3
declare -i TOTAL=0
declare -i COUNT=0
@scottcreynolds
scottcreynolds / gist:1577209
Created January 8, 2012 04:28
GOP Rails Models for Marriage
#normal, rational human beings with no religious agenda
class Marriage < ActiveRecord::Base
validates :human_one, :human_two, :presence => true
end
#standard GOP/Fundamentalist Model
class Marriage < ActiveRecord::Base
validates :husband, :uniqueness => true, :presence => true,
:male => true, :message => "It's ADAM, not MADAM"
validates :wife, :uniqueness => true, :presence => true,
@sigerello
sigerello / README.markdown
Created October 8, 2011 06:12 — forked from dora-gt/README.markdown
How to install MongoDB 2.0 on Mac OS X (>= Leopard)

How to install MongoDB 2.0 on Mac OS X (>= Leopard)

Procedure

The whole install procedure is like the following.
You would have to do 7 steps.

  1. Download the latest tar file, and expand it.
  2. Move it to /usr/local/, and make a symbolic link to the folder.
  3. Add path to MongoDB binaries.
  4. Make an user that "mongod" runs on, and group that owns the user.