Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| #!/bin/bash | |
| function flask-boilerplate-tmux | |
| { | |
| # https://github.com/swaroopch/flask-boilerplate | |
| BASE="$HOME/code/flask-boilerplate" | |
| cd $BASE | |
| tmux start-server | |
| tmux new-session -d -s flaskboilerplate -n model |
| application: you-app-name-here | |
| version: 1 | |
| runtime: python | |
| api_version: 1 | |
| default_expiration: "30d" | |
| handlers: | |
| - url: /(.*\.(appcache|manifest)) | |
| mime_type: text/cache-manifest |
| require 'active_record' | |
| require 'arel' | |
| # Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
| # | |
| # What you would usually write like this: | |
| # | |
| # User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
| # | |
| # can now be written like this (note those parentheses required by the operators precedences): |
| # uber-hacky dynamic collection names for MongoID models: | |
| # | |
| # class MyModel | |
| # include Mongoid::PrefixableDocument # ...instead of Mongoid::Document | |
| # include Mongoid::Timestamps | |
| # | |
| # field :foobar, :type => Integer | |
| # | |
| # def my_method; 123; end | |
| # |
| require 'rubygems' | |
| require 'bundler/setup' | |
| require 'mongoid' | |
| Mongoid.configure do |config| | |
| config.master = Mongo::Connection.new('localhost', 27017, :logger => nil).db('mongoid-test') | |
| end | |
| class A | |
| include Mongoid::Document |
| #Simple form Input class for arrays | |
| class ArrayInput < SimpleForm::Inputs::Base | |
| def input | |
| #override the attribute name for arrays to allow rails to handle array forms | |
| input_html_options.merge!({:name => "#{self.object_name}[#{attribute_name}][]"}) | |
| @builder.text_field(attribute_name, input_html_options) | |
| end | |
| end |
| defmodule Extension do | |
| defmacro extends(module) do | |
| # As above... | |
| end | |
| defmacro implements(module, protocol: protocol) do | |
| quote do | |
| defimpl unquote(protocol), for: unquote(module) do | |
| import Extension |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| #!/bin/bash | |
| # Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/ | |
| set -e | |
| sourceApp="$1" | |
| targetApp="$2" | |
| while read key value; do |