Skip to content

Instantly share code, notes, and snippets.

@mba811
mba811 / making-dash-doctests-using-sphinx-and-doc2dash.html
Created April 16, 2015 13:26
making-dash-doctests-using-sphinx-and-doc2dash
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>
Making dash doctests using sphinx and doc2dash | EF
</title>
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://nafiulis.me/theme/css/main.css"/>
@mba811
mba811 / markdown.rb
Created April 16, 2015 08:25
Only support redcarpet with rouge as syntax highlighter.(kitabu)
module Kitabu
module Markdown
class Renderer < Redcarpet::Render::HTML
include Redcarpet::Render::SmartyPants
include Rouge::Plugins::Redcarpet
end
class << self
# Set markdown renderer
attr_accessor :processor
@mba811
mba811 / config.ru
Created April 15, 2015 14:09
So now we have PHP 5.4 with php-cgi installed. We can now setup our PHP site using Pow! All we have to do is create our config.ru
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
INDEXES = [ 'index.html' , 'index.php' , 'index.cgi' ]
ENV [ 'SERVER_PROTOCOL' ] = "HTTP/1.1"
use Rack : :Rewrite do
rewrite %r{(.*/$)} , lambda { | match , rack_env |
@mba811
mba811 / Podcasts.Applescript
Created April 15, 2015 13:27
控制Podcasts播放速度,还能调用具备快进/快退功能的Quicktime来播放Podcasts节目
tell application "iTunes"
set setupNeeded to false
--fetch prior selected playlist name and playback rate
try
set targetPlaylistName to do shell script "defaults read com.jeffporten.fastpodcast SelectedPlaylist"
set playbackRate to do shell script "defaults read com.jeffporten.fastpodcast PlaybackRate"
on error -- probably first run of script
set setupNeeded to true
@mba811
mba811 / sample.rb
Created April 15, 2015 02:37
Generate cheat sheets for Dash-cheatset
cheatsheet do
title 'Sample' # Will be displayed by Dash in the docset list
docset_file_name 'Sample' # Used for the filename of the docset
keyword 'sample' # Used as the initial search keyword (listed in Preferences > Docsets)
# resources 'resources_dir' # An optional resources folder which can contain images or anything else
introduction 'My *awesome* cheat sheet' # Optional, can contain Markdown or HTML
# A cheat sheet must consist of categories
category do
@mba811
mba811 / pgdoc2set.py
Created April 15, 2015 02:18
PostgreSQL docset for Dash (http://kapeli.com/dash/)
#!/usr/local/bin/python
import os, re, sqlite3
from bs4 import BeautifulSoup, NavigableString, Tag
db = sqlite3.connect('postgresql.docset/Contents/Resources/docSet.dsidx')
cur = db.cursor()
try: cur.execute('DROP TABLE searchIndex;')
except: pass
@mba811
mba811 / passenger.conf
Created April 14, 2015 04:11
OS X development environment
LoadModule passenger_module /usr/local/opt/passenger/libexec/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/opt/passenger/libexec/lib/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
@mba811
mba811 / mysql aliases
Created April 14, 2015 04:10
OS X development environment
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
sudo mkdir /var/mysql
sudo ln -d /tmp/mysql.sock /var/mysql/mysql.sock
@mba811
mba811 / (php)httpd.conf
Created April 14, 2015 04:09
OS X development environment
LoadModule php5_module libexec/apache2/libphp5.so
DocumentRoot "/Users/quick/www"
<Directory "/Users/quick/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
@mba811
mba811 / (passenger)httpd.conf
Created April 14, 2015 04:06
OS X development environment
RailsEnv development
<Location /rubyapp>
PassengerAppRoot /Users/quick/www/rubyapp
RackBaseURI /rubyapp
Options -MultiViews
</Location>