Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Hedberg gemfarmer

View GitHub Profile
@gemfarmer
gemfarmer / rspec_rails_cheetsheet.rb
Created Jun 30, 2019 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
View SDFlash2.ino
// This #include statement was automatically added by the Particle IDE.
#include "Particle.h"
#include "system_update.h"
int fileSize;
void poll();
void setupOpenLog(void);
void readFirmware(char *fileName);
View FlashTinkerFailing.ino
#include "Particle.h"
#include "system_update.h"
SerialDebugOutput debugOutput(9600, ALL_LEVEL);
void flashTinker(); // forward declaration
bool uploaded = false;
@gemfarmer
gemfarmer / SDFlash.ino
Last active Mar 12, 2019
Read Firmware from SD Card, Flash to P1
View SDFlash.ino
#include "Particle.h"
#include "system_update.h"
bool uploaded = false;
SerialDebugOutput debugOutput(9600, ALL_LEVEL);
// float dummyVoltage = 3.50; //This just shows to to write variables to OpenLog
// char mystr[13]; //Initialized variable to store recieved data
void setup() {
View gitignore_already_tracked_file.md

Git: How can I ignore a file that is already committed to the repo?

You have a repo and quite some developers have cloned the repo and working on it. Now you want to add a file to gitignore which is already checked-in or tracked by Git.(The file is already commited into the repo)

Below are the steps on how to ignore this file (lets say the filename is config.py):

  • Add it to .gitignore:

       $ echo "config.py" >> .gitignore
@gemfarmer
gemfarmer / migrate_postgresql_database.md
Created Jun 18, 2017 — forked from olivierlacan/migrate_postgresql_database.md
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X
View migrate_postgresql_database.md

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

@gemfarmer
gemfarmer / 18f-pride.svg
Last active Jun 1, 2017
18f pride logo
View 18f-pride.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gemfarmer
gemfarmer / reset_audio.md
Last active Apr 21, 2017
Reset system sound for Hangouts
View reset_audio.md

To reset the system sound for Hangouts, run (only works in OSX):

sudo kill -9 `ps ax|grep 'coreaudio[a-z]' |awk '{print $1}'`
@gemfarmer
gemfarmer / README.md
Last active Apr 17, 2017
Script to crawl a yaml list of broken urls and determine where they were moved to..
View README.md

To run this script,

  1. Add crawl_broken_urls.rb to you directory
  2. At the same directory level, add a broken_links.yml.
  3. Then run ruby crawl_broken_urls.rb
@gemfarmer
gemfarmer / README.md
Last active Mar 23, 2017
Bash script that kills a process
View README.md

Usage

This script will kill the pid process that is responsible for keeping a port open. Use as follows to kill the process that corresponds to a given port:

./killport [PORT]

If the command killport is not recognized, make it executable:

You can’t perform that action at this time.