A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()):
- Headers
- Links
- Bold
| # app/controllers/application.rb | |
| class ApplicationController < ActionController::Base | |
| before_filter :modify_protocol | |
| private | |
| def modify_protocol | |
| returning(true) do | |
| if Rails.configuration.protocol_modifier |
| from redis import Redis | |
| import simplejson | |
| class Resque(object): | |
| """Dirt simple Resque client in Python. Can be used to create jobs.""" | |
| redis_server = 'localhost:6379' | |
| def __init__(self): | |
| host, port = self.redis_server.split(':') | |
| self.redis = Redis(host=host, port=int(port)) |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # Example of Singleton design pattern | |
| # Copyright (C) 2011 Radek Pazdera | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation, either version 3 of the License, or | |
| # (at your option) any later version. |
| # # your config.ru | |
| # require 'unicorn_killer' | |
| # use UnicornKiller::MaxRequests, 1000 | |
| # use UnicornKiller::Oom, 400 * 1024 | |
| module UnicornKiller | |
| module Kill | |
| def quit | |
| sec = (Time.now - @process_start).to_i | |
| warn "#{self.class} send SIGQUIT (pid: #{Process.pid})\talive: #{sec} sec" |
| // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
| // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
| // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
| // MIT license | |
| (function() { | |
| var lastTime = 0; | |
| var vendors = ['ms', 'moz', 'webkit', 'o']; |
| #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) |
A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()):
Locate the section for your github remote in the .git/config file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
| # from http://stackoverflow.com/questions/4103773/efficient-way-of-having-a-function-only-execute-once-in-a-loop | |
| from functools import wraps | |
| def run_once(f): | |
| """Runs a function (successfully) only once. | |
| The running can be reset by setting the `has_run` attribute to False | |
| """ | |
| @wraps(f) | |
| def wrapper(*args, **kwargs): | |
| if not wrapper.has_run: |
A timeline of the last four years of detecting good old window.localStorage.
October 2009: 5059daa