Skip to content

Instantly share code, notes, and snippets.

View mikew's full-sized avatar

mikew mikew

  • 709scene
  • St. John's, Newfoundland
View GitHub Profile
@mikew
mikew / README.md
Last active December 20, 2015 21:59

Getting Started

curl -Ls https://gist.github.com/mikew/6201414/raw/b3961b77d82e061e0d7dba9f668e8c282bafb0b9/setup-cloud9.sh | bash

This will create a folter at $HOME/plexmediaserver, download the plexmediaserver.rpm for CentOS/x86_64 and extract it.

You will still need the Framework.bundle from an existing Plex Media Server install placed in $HOME/plexmediaserver.

@mikew
mikew / __init__.py
Last active December 14, 2015 02:09
How to get Log, Dict, XML, et al from Plex plugin __init__.py to Shared/Libraries
# Contents/Code/__init__.py
import bridge
import library
to_export = dict(Log = Log, Dict = Dict)
bridge.init(**to_export)
def Start():
library.test()
#!/usr/bin/env ruby
require 'rexml/document'
require 'open-uri'
include REXML
USAGE = <<EOS
Usage: #{$0} [movie,show]
Marks all items in a Plex library as watched.
@mikew
mikew / recipe.sh
Last active December 11, 2015 08:58 — forked from okossuth/mechanize for kivy
#!/bin/bash
VERSION_mechanize=
URL_mechanize=http://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz
MD5_mechanize=
BUILD_mechanize=$BUILD_PATH/mechanize/$(get_directory $URL_mechanize)
RECIPE_mechanize=$RECIPES_PATH/mechanize
function prebuild_mechanize() {
true
Example:
<%= link_to_named_routes :hello, [ :world, :foo, :bar ], :base_class => 'tabs' %>
Will give you:
<ul class="tabs depth-0">
<li class="active">
<a href="/hello">Hello!</a>
</li>
class RegistrationsController < ApplicationController
STEP_VALIDATIONS = [
%w(first_name last_name),
%w(billing_address)
]
def new
@user = User.new
end
class BooksController < ApplicationController
def index
@books = resources
end
private
def resources
administrator? ? Book.all : Book.published
end
end
# shoulda validation that a partial has been rendered by a view
class Test::Unit::TestCase
def self.should_render_partial(partial)
should "render partial #{partial.inspect}" do
# add the underscore. it's expected anyways
assert_template :partial => partial.to_s.sub(/\/(\w+)$/, '/_\1')
end
end
class ActionController::TestCase
# setup :mock_warden
teardown :cleanup_warden_env
def warden
@_warden ||= mock
end
def mock_warden_for(*scopes)
scopes.each do |scope|
@mikew
mikew / README
Created October 8, 2009 21:21
Convenience methods for Rails' flashes with I18n support
Given
class Post < ActiveRecord::Base
def to_s; title; end
end
Then
notice :create => :post
# flash[:notice] = I18n.t :"post.create.notice", :scope => [ :flashes ], :post => @post.to_s