Skip to content

Instantly share code, notes, and snippets.

View danielbwa's full-sized avatar

Daniel Bakker danielbwa

View GitHub Profile
@danielbwa
danielbwa / Heroku database reset
Last active August 29, 2015 14:07
Heroku db reset
$ heroku pg:reset DATABASE_URL
$ heroku run rake db:migrate
$ heroku run rake db:seed
=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')
@danielbwa
danielbwa / gist:7181067
Last active December 26, 2015 16:38
memcache to php on OSX 10.9
Install memcached with PHP support on OSX:
Download PEAR
curl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar
Configure and Install PEAR
You should now be at a prompt to configure PEAR.
@danielbwa
danielbwa / list_and_download_files_through_sftp_with_php.php
Last active November 16, 2022 09:38
List and download all files in a directory through sftp with php / ssh2. In my example i use scandir to list the files and ssh2_scp_recv to grab a file. I've found a lot of examples using fopen to grab the remote file, that didn't work for me and i found the code below cleaner than the fopen option. For an example on how to do the same as my exa…
<?php
$username = "your_username";
$password = "your_pass";
$url = 'your_stp_server_url';
// Make our connection
$connection = ssh2_connect($url);
// Authenticate
# compare 2 dirs, remove -q to see full output
diff -rq dirA dirB
# create tar and exclude dir
tar -cvf name.tar --exclude "/full/path/dir/exclude_this" /full/path/dir/
@danielbwa
danielbwa / registrations_controller.rb
Created April 4, 2012 10:55 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else