Skip to content

Instantly share code, notes, and snippets.

View brunnogomes's full-sized avatar

Brunno Gomes brunnogomes

View GitHub Profile
@brunnogomes
brunnogomes / heroku_database_copy.md
Created August 30, 2022 12:42 — forked from kosyfrances/heroku_database_copy.md
To copy heroku database from one app to another and from local to heroku

To copy database from one heroku app to another -

heroku pg:backups capture [database_name]
heroku pg:backups restore $(heroku pg:backups public-url --app source_app) DATABASE_URL --app target_app

You can refer to https://devcenter.heroku.com/articles/heroku-postgres-backups for more information.

To copy database from local to heroku - Dump your local database in compressed format using the open source pg_dump tool: PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump where myuser is your database username and mydb is the database name.

@brunnogomes
brunnogomes / install_node.sh
Created September 27, 2021 15:46
Install LTS NodeJS on Mac with M1 chip
NODEJS_CONFIGURE_OPTIONS='--with-intl=full-icu --download=all' NODEJS_CHECK_SIGNATURES="no" asdf install nodejs ref:v14.17.6
mv ~/.asdf/installs/nodejs/{ref-v14.17.6,14.17.6}
asdf reshim nodejs
@brunnogomes
brunnogomes / instructions.md
Last active May 27, 2020 00:08
Install an old Ruby version < 2.4 using ruby-install on macOS Mojave and newer
$ brew install rbenv/tap/openssl@1.0
$ ruby-install ruby 2.2.0 -- --with-openssl-dir=$(brew --prefix openssl@1.0)

$ gem install bundler -v '~>1'

@brunnogomes
brunnogomes / commands.sh
Created January 21, 2020 13:13
Fixing XCode related errors with NodeJS, Yarn etc.
# if you get errors like:
# xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a
# command line tools instance
# or:
# xcode-select: error: command line tools are already installed, use “Software Update” to install updates
# run these if you already have XCode installed (these will config command line tools to use XCode's executables)
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
@brunnogomes
brunnogomes / clean-up-boot-partition-ubuntu.md
Created September 17, 2018 14:26 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@brunnogomes
brunnogomes / strategic_merge.sh
Created July 6, 2018 22:28
Promote alternate git branch to master branch
# We actually don't need to do that.
# Even if the branches are very different and you don't wanto resolve a ton of conflicts.
# Using the strategy argument in the merge command, you can instruct git to just use
# tha state in the current branch and do the merge, preserving all the history.
git checkout alternate_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge alternate_branch # fast-forward master up to the merge
# Now you can delete the alternate_branch and go back to using master.
1. go to https://sslvpn.demo.sonicwall.com/cgi-bin/welcome
2. log in with demo/password
3. click on NetExtender icon, this will download a tar.gz with the client
4. sudo ln -s /lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/libssl.so.6
5. sudo ln -s /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/libcrypto.so.6
6. un-tar the client, make install script executable and launch install
@brunnogomes
brunnogomes / application_controller.rb
Last active September 29, 2015 20:44
Simple CORS in Rails (just for development please)
# other stuff...
after_action :set_cors_headers # use after_filter if Rails < 4
def set_cors_headers
headers['Access-Control-Allow-Origin'] = "*"
headers['Access-Control-Request-Method'] = %w{GET POST OPTIONS}.join(",")
end
# other stuff...
@brunnogomes
brunnogomes / break_string_by_chunk_size.rb
Created August 20, 2015 15:45
Using Ruby to break text by chunk size, preserving full words (does not break a word in two parts).
text = "Lorem ipsum dolor sit amet, vix agam noluisse inciderint ea, ex augue iriure invidunt nec. Discere epicuri vim in, et delenit molestie adolescens eam. Ei pericula explicari principes nec, solum salutatus intellegam ei sed. Ei vix stet debet vocibus. Pri viris aperiri periculis ei, pri vocibus tacimates id."
text.scan(/.{1,25}\b|.{1,25}/).map(&:strip)
# => ["Lorem ipsum dolor sit", "amet, vix agam noluisse", "inciderint ea, ex augue", "iriure invidunt nec.", "Discere epicuri vim in,", "et delenit molestie", "adolescens eam. Ei", "pericula explicari", "principes nec, solum", "salutatus intellegam ei", "sed. Ei vix stet debet", "vocibus. Pri viris", "aperiri periculis ei, pri", "vocibus tacimates id", "."]
@brunnogomes
brunnogomes / robot.js
Created December 4, 2012 00:53
The Garbage Collector
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.fire();