Skip to content

Instantly share code, notes, and snippets.

1. Imperative programming
var i = 1;
while i <= 100 {
if i % 3 == 0, i % 5 == 0 {
print("fizzbuzz")
} else if i % 3 == 0 {
print("fizz")
} else if i % 5 == 0 {
print("buzz")
} else {
@Cambero
Cambero / sidekiq_web
Created April 21, 2021 08:20 — forked from ddrscott/sidekiq_web
Standalone Sidekiq Web Server
#!/usr/bin/env ruby
# Run Sidekiq Web Standalone
require 'rack'
require 'sidekiq'
require 'sidekiq-ent'
require 'sidekiq-pro'
Sidekiq.configure_client do |config|
config.redis = { :size => 1 }
@Cambero
Cambero / clear-sidekiq-jobs.sh
Created April 21, 2021 07:41 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@Cambero
Cambero / app-lib-subdomain_constraint.rb
Created April 19, 2021 09:56 — forked from JeremiahChurch/app-lib-subdomain_constraint.rb
Custom Subdomains from Models in Rails & Rspec testing too
class SubdomainConstraint
# used in routes to generate subdomains
# note there is a cache buster in company.rb in case the subdomain is updated - `reload_routes`
# update it if we write any additional cache entries here
RESERVED_SUB_DOMAINS = %w[
www app admin test staging help support wwww cdn owner media intercom mail r _domainkey blog webhooks webhook
hooks api api-test api-staging referral outbound mail webmail w3 mailboxes io heroku inbound google search
].freeze
@Cambero
Cambero / web-fonts-asset-pipeline.md
Created April 15, 2021 09:50 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@Cambero
Cambero / clamav-mac.md
Created March 30, 2021 09:55 — forked from mendozao/clamav-mac.md
Get ClamAV running on Mac OS X (using Homebrew)

Get ClamAV running on Mac OS X (using Homebrew)

The easiest way to get the ClamAV package is using Homebrew

$ brew install clamav

Before trying to start the clamd daemon, you'll need a copy of the ClamAV databases.

Inside /your/location/to/brew/etc/clamav, you'll see 2 files:

@Cambero
Cambero / multiple-git-hooks.sh
Created April 3, 2020 08:05 — forked from mjackson/multiple-git-hooks.sh
Run multiple scripts for the same git hook
#!/bin/sh
# This script should be saved in a git repo as a hook file, e.g. .git/hooks/pre-receive.
# It looks for scripts in the .git/hooks/pre-receive.d directory and executes them in order,
# passing along stdin. If any script exits with a non-zero status, this script exits.
script_dir=$(dirname $0)
hook_name=$(basename $0)
hook_dir="$script_dir/$hook_name.d"
@Cambero
Cambero / alias_matchers.md
Created October 9, 2019 06:56 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@Cambero
Cambero / alias_matchers.md
Created October 9, 2019 06:56 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value