Skip to content

Instantly share code, notes, and snippets.

View jjercx's full-sized avatar

Juan José Ramírez Calderón jjercx

View GitHub Profile
@jjercx
jjercx / juanjo-light.itermcolors
Created August 17, 2020 14:54
custom light colors for iterm2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
@ntamvl
ntamvl / create-ruby-gem-that-adds-rake-tasks.md
Last active February 16, 2024 19:13
How to create a Ruby gem that adds Rake tasks

How to create a Ruby gem that adds Rake tasks

Create a gem

One way to do this is to use bundler to scaffold our gem:

bundler gem my_gem

Add rake tasks to our gem

I prefer to put tasks meant to manage the gem itself in lib/tasks, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks.

@FradSer
FradSer / iterm2_switch_automatic.md
Last active April 23, 2024 02:40
Switch iTerm2 color preset automatic base on macOS dark mode.

The latest beta (3.5) includes separate color settings for light & dark mode. Toggling dark mode automatically switches colors.

Vist iTerm2 homepage or use brew install iterm2-beta to download the beta. Thanks @stefanwascoding.


  1. Add switch_automatic.py to ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch with:
@scokmen
scokmen / HttpStatusCode.ts
Created April 25, 2017 11:10
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
@zulhfreelancer
zulhfreelancer / readline_bundle_image_not_found.md
Last active November 3, 2021 20:50
How to fix 'readline.bundle image not found' problem?

If you get error like this:

Running via Spring preloader in process 7662
/Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
@abhinavmsra
abhinavmsra / rspec_json_helper.md
Created July 11, 2016 09:13
DRY JSON Parsing in Rspec Tests
# spec/support/request_helpers.rb
module Requests
  module JsonHelpers
    def json
      JSON.parse(response.body)
    end
  end
end
@gonzalezreal
gonzalezreal / ios-cell-registration-swift.md
Last active March 13, 2024 15:18
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active April 21, 2024 02:41
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@dmilisic
dmilisic / active_record_enum_with_rails_admin.rb
Last active January 21, 2022 10:50
Initializer for handling ActiveRecord (4.1+) enums by RailsAdmin (0.6.2)
module ActiveRecord
module RailsAdminEnum
def enum(definitions)
super
definitions.each do |name, values|
define_method("#{ name }_enum") { self.class.send(name.to_s.pluralize).to_a }
define_method("#{ name }=") do |value|
if value.kind_of?(String) and value.to_i.to_s == value
@mattlewissf
mattlewissf / add-p.md
Last active April 23, 2024 09:19
Lightning Talk: Git add -p

git add -p is your friend

git add -p is basically "git add partial (or patch)"

Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.

It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:

from the command line, either use

  • git add -p