Skip to content

Instantly share code, notes, and snippets.

View derekbarber's full-sized avatar

Derek Barber derekbarber

View GitHub Profile
@derekbarber
derekbarber / DownloadAndSaveAudioFile.swift
Created September 24, 2020 23:30 — forked from UmairSharif99/DownloadAndSaveAudioFile.swift
Function to download audio file from url and save it in documents directory
func downloadAndSaveAudioFile(_ audioFile: String, completion: @escaping (String) -> Void) {
//Create directory if not present
let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentDirectory = paths.first! as NSString
let soundDirPathString = documentDirectory.appendingPathComponent("Sounds")
do {
try FileManager.default.createDirectory(atPath: soundDirPathString, withIntermediateDirectories: true, attributes:nil)
print("directory created at \(soundDirPathString)")
@derekbarber
derekbarber / db.rake
Created September 21, 2020 20:39 — forked from khalilgharbaoui/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92
namespace :db do
desc 'Dumps the database to backups'
task dump: :environment do
dump_fmt = ensure_format(ENV['format'])
dump_sfx = suffix_for_format(dump_fmt)
backup_dir = backup_directory(Rails.env, create: true)
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

<div class="dropdown-menu dropdown-menu-fit dropdown-menu-right dropdown-menu-anim dropdown-menu-top-unround dropdown-menu-sm show" style="width: 240px; position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(970px, 71px, 0px);" x-placement="bottom-end">
<div class="kt-user-card kt-margin-b-40 kt-margin-b-30-tablet-and-mobil" style="background-image: url(/packs/media/images/keen/misc/head_bg_sm-66cadb6d43cfd231fc863b7e775886a1.jpg)">
<div class="kt-user-card__wrapper">
<div class="kt-user-card__pic">
<img class="kt-rounded" src="http://gravatar.com/avatar/2f1af9ac1462a8524608d19e83f3d25e?size=40">
</div>
<div class="kt-user-card__details">
<div class="kt-user-card__name">Derek Barber</div>
<div class="kt-user-card__position">Family Member</div>
</div>
/*!
* froala_editor v2.7.1 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2017 Froala Labs
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
@derekbarber
derekbarber / nginx-config-rails4-with-puma-ssl-version.conf
Last active September 2, 2015 18:06 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')

Keybase proof

I hereby claim:

  • I am derekbarber on github.
  • I am derekbarber (https://keybase.io/derekbarber) on keybase.
  • I have a public key whose fingerprint is 95B4 AFE8 EE0C D4B6 9017 843E 3C47 FA00 438A D295

To claim this, I am signing this object:

How to reset postgres' primary key sequence when it falls out of sync?
heroku pg:psql
-- Login to psql and run the following
-- What is the result?
SELECT MAX(id) FROM your_table;
-- Then run...
-- This should be higher than the last result.

To drop the database:

heroku pg:reset DATABASE

To recreate the database:

heroku run rake db:migrate

To populate the database with seed data: