Skip to content

Instantly share code, notes, and snippets.

View porty's full-sized avatar

Robert McNeil porty

View GitHub Profile
@porty
porty / ruby_rspec_snippets.md
Last active January 3, 2016 10:29
Ruby and/or Rails and/or RSpec snippets

Mock a static method on MyClass:

allow(MyClass).to receive(:my_method).with(1, 2, kind_of(Object)) { 'SOUNDS GOOD' }

To fail if it doesn't get called, use expect instead of allow

To mock a method on any instances of MyClass:

@porty
porty / guzzle_stub.php
Created January 19, 2014 22:38
Guzzle HTTP stub classes (replaced by SimpleTest mocking)
class GuzzleResponseStub
{
public function isSuccessful()
{
return true;
}
public function json()
{
@porty
porty / pxe-things.md
Last active January 3, 2016 20:59
PXE things
@porty
porty / show_image.html
Last active August 29, 2015 13:56
Show me an image plz
<html>
<head>
<style>
body {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
</style>
<script>
@porty
porty / linux_vs_mac_for_dev.md
Last active August 29, 2015 13:56
Linux vs. Mac for dev

Issues

  • Battery usage in general
    • Device drivers :(
  • All "productivity" software sucks
    • I am not a fan of Open/Libre office or Google docs :(

Software

@porty
porty / ubuntu_core_installer.sh
Last active August 29, 2015 13:56
Ubuntu Core Installer
#!/bin/bash
#
# Ubuntu core filesystem makerer
#
# http://www.omappedia.com/wiki/OMAP_Ubuntu_Core
#
set -e
@porty
porty / ui_for_tools.md
Created March 16, 2014 06:24
User Interface for Tools

Scalability

For example, a good interface will pop up a "search" box for finding a security group in Active Directory. A bad one will let me chose security groups from a list or a drop-down. Both look equally good when the developer is working in a test environment. The latter will crash when used in a million-object directory. Similarly, check out the DNS management dialog box in Windows, or some Oracle tools. Both will show you "all" objects up to some limit (e.g.: 5000), but then provide a filter option to allow you to narrow down the "search" to prevent the GUI from melting if you look at a database with 500K tables. Yes. It happens. A lot. More than you think. Really.

Annotations

It's 2014 for Christ's sake! There is absolutely no reason not to include a general "note" or at least a "description" field with every. Single. Thing. Seriously. All of them. I'm not kidding. Look at VMware's vSphere interface as an example of this done reasonably well but not perfectly. They at least allow custom colu

@porty
porty / eventbrite_logos.md
Last active August 29, 2015 13:57
Eventbrite logos

http://imgur.com/a/sE8xQ

cd ~/Projects/raspberry-screens

# white
`which pip`/../python ./local_screens.py set pi-east-north "http://10.99.1.77/show_image.html?color=white&img=http://i.imgur.com/X6XR7HE.jpg"

# black
@porty
porty / .bash_aliases
Last active August 29, 2015 13:57
Contests .bash_aliases
# tail the apache logs without other cruft
alias log1="tail -f /var/log/apache2/error.log | egrep -v --line-buffered '(CSRF|Load existing customer|rotatelogs|Could not open log file)'"
# tail contests logs
alias log2="sudo supervisorctl tail -f contests-worker-dev"
# tail commerce logs
alias log3="sudo supervisorctl tail -f commerce-worker-dev"
# start the things that didn't start automatically