Skip to content

Instantly share code, notes, and snippets.

View EdgarOrtegaRamirez's full-sized avatar
📝
​Learning!

Edgar Ortega EdgarOrtegaRamirez

📝
​Learning!
View GitHub Profile
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / script.sh
Created April 9, 2018 04:45
Cyrstal PKG_CONFIG_PATH macOS High Sierra
# Package libssl was not found in the pkg-config search path.
# Perhaps you should add the directory containing `libssl.pc'
# to the PKG_CONFIG_PATH environment variable
# No package 'libssl' found
# Package libcrypto was not found in the pkg-config search path.
# Perhaps you should add the directory containing `libcrypto.pc'
# to the PKG_CONFIG_PATH environment variable
# No package 'libcrypto' found
export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / script.sh
Last active April 7, 2018 21:48
Install Java10 Linux
mkdir ~/java10
cd ~/java10
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10+46/76eac37278c24557a3c4199677f19b62/jdk-10_linux-x64_bin.tar.gz
tar -zxvf jdk-10_linux-x64_bin.tar.gz
cd jdk-10/
update-alternatives --install /usr/bin/java java ~/java10/jdk-10/bin/java 100
update-alternatives --config java
update-alternatives --install /usr/bin/javac javac ~/java10/jdk-10/bin/java 100
update-alternatives --config javac
update-alternatives --install /usr/bin/jar jar ~/java10/jdk-10/bin/jar 100
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / memory.rb
Last active April 25, 2018 22:20
Ruby Memory and Time Usage script
def print_memory_usage
memory_before = `ps -o rss= -p #{Process.pid}`.to_i
yield
memory_after = `ps -o rss= -p #{Process.pid}`.to_i
puts "Memory: #{((memory_after - memory_before) / 1024.0).round(2)} MB"
end
def print_time_spent
time = Benchmark.realtime do
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / setup.sh
Last active January 23, 2017 03:49
Setup Mac for Development
cd ~
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew analytics off
brew doctor
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
\curl -sSL https://get.rvm.io | bash -s stable
source /Users/edgarortega/.rvm/scripts/rvm
type rvm | head -1
rvm -v
brew install git node vim postgres tmux yarn ag
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / ssl.rb
Last active January 14, 2021 19:50
Ruby: Disable OpenSSL certificate verification
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
def gen(nums, digit)
result = []
nums.each_with_index do |num, i|
slice = nums[i, digit]
tmp = slice.concat(nums[i + digit])
result.push(tmp)
end
result
end
gen([0,1,2],1)
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / brew.sh
Last active March 8, 2016 14:16
Update and Clean Up Brew
brew update && brew upgrade --all && brew cleanup && brew prune
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / migration.rb
Created May 23, 2015 18:27
Users - Followers - Following
class CreateRelations < ActiveRecord::Migration
def change
create_table :relations do |t|
t.references :user, index: true, foreign_key: true
t.integer :friend_id, index: true
t.timestamps null: false
end
end
end
# Hides Draper decorator inside the model and lazily decorates resources
#
# https://gist.github.com/firedev/7a82059b30a2157d4c56
#
# model.rb:
# include Decorated
#
# Just make sure there are no overlapping method names in ModelDecorator
module Decorated
# config/routes.rb
resources :documents do
resources :versions, controller: "documents/versions" do
post :restore, on: :member
end
resource :lock, controller: "documents/locks"
end