Skip to content

Instantly share code, notes, and snippets.

View mosdevly's full-sized avatar

Mosdev mosdevly

  • San Francisco, CA
View GitHub Profile
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@mosdevly
mosdevly / binary_search.py
Created March 10, 2018 04:41
Binary Search in Python
# iterative implementation of binary search in Python
def binary_search(a_list, item):
"""Performs iterative binary search to find the position of an integer in a given, sorted, list.
a_list -- sorted list of integers
item -- integer you are searching for the position of
"""
@mosdevly
mosdevly / util.py
Created March 25, 2017 19:47 — forked from kgriffs/util.py
Deprecated decorator for Python. Uses clever introspection to set a helpful filename and lineno in the warning message.
import functools
import inspect
import warnings
# NOTE(kgriffs): We don't want our deprecations to be ignored by default,
# so create our own type.
class DeprecatedWarning(UserWarning):
pass
@mosdevly
mosdevly / deprecated.py
Created March 25, 2017 19:45 — forked from Xion/deprecated.py
@deprecated decorator for Python classes
import functools
import inspect
import os
import warnings
class _DeprecatedDecorator(object):
MESSAGE = "%s is @deprecated"
def __call__(self, symbol):
@mosdevly
mosdevly / beautiful_idiomatic_python.md
Created February 18, 2017 06:09 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@mosdevly
mosdevly / jenkins-notes.md
Created December 1, 2016 05:52 — forked from misterbrownlee/jenkins-notes.md
Jenkins setup

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins

@mosdevly
mosdevly / sounder.rb
Created June 27, 2016 21:55 — forked from jashkenas/sounder.rb
A Demonstration of Minim in Ruby-Processing
# Sounder sounds for class
# Requires an active microphone to pick up anything
require 'ruby-processing'
class MinimTest < Processing::App
load_library "minim"
import "ddf.minim"
import "ddf.minim.analysis"
@mosdevly
mosdevly / keypress.rb
Created November 22, 2015 00:55 — forked from acook/keypress.rb
Read keypresses from user in terminal, including arrow keys using pure Ruby. This has since been folded into a much more robust gem called Remedy. https://rubygems.org/gems/remedy & https://github.com/acook/remedy
require 'io/console'
# Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char
STDIN.echo = false
STDIN.raw!
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
@mosdevly
mosdevly / jenkins.sh
Last active August 29, 2015 14:27 — forked from dexterous/jenkins.sh
template jenkins/hudson build script for python with virtualenv
# WORKSPACE set to job workspace by jenkins/hudson
VENV="$WORKSPACE/.env"
if [ ! -e "$VENV" ]; then
virtualenv --python python2.6 --no-site-packages $VENV
elif [ ! -d "$VENV" ]; then
echo '$VENV exists but is not a directory'
exit 1
fi
@mosdevly
mosdevly / gist:36a18c48992e77d0cf85
Last active August 29, 2015 14:27 — forked from learncodeacademy/gist:5f84705f2229f14d758d
Getting Started with Vagrant, SSH & Linux Server Administration