Skip to content

Instantly share code, notes, and snippets.

View bishopandco's full-sized avatar
😈
CRUSHMODE

Michael Bishop bishopandco

😈
CRUSHMODE
View GitHub Profile
def snippet(thought, wordcount)
thought.split[0..(wordcount-1)].join(" ") +(thought.split.size > wordcount ? "..." : "")
end
#!/usr/bin/env python
# Convert a mysql dump into a sqlite-compatible format.
# I wrote this for just one script... no guarantess that it will work with others...
# python fsql.py < mysqldump.sql > readyforsqlite.sql
import re
import sys
content = sys.stdin.read()
namespace(:db) do
desc "Pulls remote DB and saves to file."
task :pull, :roles => :web do
load 'config/environment.rb'
abcs = ActiveRecord::Base.configurations
curr_date = Time.new
timestamp = curr_date.mon.to_s + "_" + curr_date.day.to_s + "_" + curr_date.hour.to_s + "_" + curr_date.min.to_s
run "mysqldump -h#{abcs[stage.to_s]["host"]} -u#{abcs[stage.to_s]["username"]} --password=#{abcs[stage.to_s]["password"]} #{abcs[stage.to_s]["database"]} > #{shared_path}/#{stage.to_s}_data_#{timestamp}.sql"
run "cd #{shared_path} && tar -czvf #{shared_path}/#{stage.to_s}_data_#{timestamp}.sql.tar.gz #{stage.to_s}_data_#{timestamp}.sql"
map.connect "faqs.html", :controller => "main", :action =>"faqs"
map.connect "faqs.php", :controller => "main", :action =>"faqs"
<VirtualHost *:80>
ServerName domain.com
DocumentRoot "/home/deploy/domain.com/current/public"
RailsEnv production
AddHandler passenger .php #added to support legacy routes
<Directory "/home/deploy/domain.com/current/public">
Order allow,deny
Allow from all
</Directory>
@tn = params[:tn][:tracking_number]
@tns = @tn.split(',')
if @tns.count >= 2
@tns.each do |tn|
@tracking_number = TrackingNumber.new
@tracking_number.tracking_number = tn
@tracking_number.order_id = @order.id
@tracking_number.save
count +=1
end
# @menu.special_action ="contact"
def show
@menu = Menu.find(params[:id])
@resource = @menu.resource
unless @menu.special_action.nil?
render @menu.special_action.to_sym
else
render 'show'
end
<ul id="id_0">
<li id="id_1">1.0</li>
<li id="id_2">2.0</li>
<li id="id_3">3.0
<ul>
<li id="id_4">3.1</li>
<li id="id_5">3.2</li>
</ul>
</li>
</ul>
map.namespace :admin do |admin|
admin.resources :news, :collection => {:post_data => :post, :sort => :post, :search => :post}
end
$ rake routes | grep news
search_admin_news POST /admin/news/search(.:format) {:controller=>"admin/news", :action=>"search"}
post_data_admin_news POST /admin/news/post_data(.:format) {:controller=>"admin/news", :action=>"post_data"}
sort_admin_news POST /admin/news/sort(.:format) {:controller=>"admin/news", :action=>"sort"}
admin_news_index GET /admin/news(.:format) {:controller=>"admin/news", :action=>"index"}