Skip to content

Instantly share code, notes, and snippets.

View fabianvelizok's full-sized avatar
🎯
Focusing

Fabian Veliz fabianvelizok

🎯
Focusing
View GitHub Profile
@rpearce
rpearce / tmp.rb
Created April 10, 2017 22:55
Rails – open a file, read it and write it to a temp file
module Tmp
def self.build(src:, name:, ext:, binmode: false)
file = Tempfile.new([name, ext], Rails.root.join('tmp'))
file.binmode if binmode
open(src) { |f| file.write(f.read) }
file.rewind
file.close
file
end
end
<?php
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
@kagemusha
kagemusha / gist:1569836
Created January 6, 2012 09:20
Dump Heroku Postgres DB and load locally
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
1. heroku pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump