Skip to content

Instantly share code, notes, and snippets.

View intrip's full-sized avatar
:octocat:
Coding, fun!

Jacopo Beschi intrip

:octocat:
Coding, fun!
View GitHub Profile
@searls
searls / whereable.rb
Created September 4, 2021 16:06
The initial implementation of a Whereable query filter for KameSame.
class Whereable
def initialize(where:, model: Item, ranking_conditions: [], valid: true, data_source: nil)
@model = model
@where = where
@data_source = data_source
@ranking_conditions = ranking_conditions
@valid = valid
end
def valid?
@baweaver
baweaver / ruby_galaxy_poker_pattern_matching.rb
Created January 28, 2021 19:53
Variant of pattern matching example from RubyGalaxy talk
class Card
SUITS = %w(S H D C).freeze
RANKS = %w(2 3 4 5 6 7 8 9 10 J Q K A).freeze
RANKS_SCORES = RANKS.each_with_index.to_h
include Comparable
attr_reader :suit, :rank
def initialize(suit, rank)
@progrium
progrium / README.md
Last active April 7, 2024 21:42
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • In general, binaries built just for x86 architecture will automatically be run in x86 mode
  • You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
  • You can force command-line apps by prefixing with arch -x86_64, for example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

@jeromedalbert
jeromedalbert / .gitattributes
Last active March 3, 2024 12:18
Automatically resolve Git merge conflicts in Rails schema.rb by picking the most recent date in the conflict (now works with Rails 5 and recent versions of Git). The following files should be in your home ~ directory. Inspired by https://tbaggery.com/2010/10/24/reduce-your-rails-schema-conflicts.html
db/schema.rb merge=railsschema
@xenogenesi
xenogenesi / Makefile
Last active November 19, 2021 03:28
create self signed certificates
DOMAIN ?= mydomain.com
COUNTRY := IT
STATE := IT
COMPANY := Evil Corp.
# credits to: https://gist.github.com/fntlnz/cf14feb5a46b2eda428e000157447309
# usage:
@rafaelfranca
rafaelfranca / 28718.rb
Last active July 4, 2022 20:11 — forked from alexcameron89/28718.rb
A Reproduction Script for Rails issue #28718
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
source "https://rubygems.org"
gem "rails", "5.0.2"
@intrip
intrip / .vimrc
Last active March 14, 2017 17:01
Custom .vimrc for ruby and javascript development
""""""""""""""""""
" Vundle options
"""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
:let mapleader = "-" " Maps - as leader character
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
@chadbrewbaker
chadbrewbaker / zdist.rb
Created January 6, 2015 02:07
Computes information distance between two files
require "zlib"
if(ARGV.length != 2)
puts "usage: ruby zdist.rb file1 file2"
else
f1 = File.read(ARGV[0])
f2 = File.read(ARGV[1])
f1d = Zlib::Deflate.deflate(f1)
f2d = Zlib::Deflate.deflate(f2)
compressed = Zlib::Deflate.deflate(f1+f2)
@nybblr
nybblr / rails-with-bower.md
Last active November 27, 2023 15:41
Rails with Bower. Without bower-rails.
@idleberg
idleberg / Install-Mcrypt.md
Last active May 31, 2023 17:13
Install Mcrypt on macOS

Setup php-mcrypt on macOS (and versions of Mac OS X)

These steps should have been mentioned in the prerequisites of the Laravel Installation Guide, since I'm surely not the only person trying to get Laravel running on macOS.

Install

Install Mcrypt using Homebrew and PECL (comes with PHP)

# PHP 7.3