Skip to content

Instantly share code, notes, and snippets.

View petros's full-sized avatar
👾
Making games

Petros Amoiridis petros

👾
Making games
View GitHub Profile
@petros
petros / new.html.erb
Created December 21, 2010 11:28
Credit card fields (Formtastic)
<% f.inputs :name => "Payment" do %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :card_type, :label => :card_type, :collection => [["Visa", "visa"], ["MasterCard", "master"], ["Discover", "discover"], ["American Express", "american_express"]] %>
<%= f.input :card_number %>
<%= f.input :card_verification, :label => 'Card Verification Value (CVV)' %>
<%= f.input :card_expires_on, :discard_day => true, :start_year => Date.today.year, :end_year => (Date.today.year+10), :add_month_numbers => true %>
<% end %>
sudo apt-get install zlib1g-dev libssl-dev libreadline5-dev libxml2-dev libsqlite3-dev
@petros
petros / gist:673510
Created November 12, 2010 00:31
Configuring git to work with vimdiff

You can configure git to work with vimdiff issuing the following two commands in terminal:

git config --global diff.tool vimdiff
git config --global difftool.prompt false

Two examples of how you can use this:

git difftool HEAD
git difftool HEAD path-and-filename-of-specific-file
@petros
petros / routes.rb
Created November 4, 2010 10:34
Rails route example that shows map.root (2.3.x)
ActionController::Routing::Routes.draw do |map|
map.resources :posts
map.resources :customers
map.resources :password_resets
map.resource :account, :controller => "users"
map.resources :users
map.resource :user_session
map.login 'login', :controller => "user_sessions", :action => "new"
map.logout 'logout', :controller => "user_sessions", :action => "destroy"
map.root :controller => "posts", :action => "index"
@petros
petros / controller.rb
Created July 13, 2010 12:16
Search conditions for a form_tag
def list_by_filter
@filterinfo = []
sql = "select i.* from installations i"
sqlconditions = ""
if params[:code] != nil
@code = params[:code]
sqlconditions += "code = '#{@code}'"
@filterinfo << "με κωδικό #{@code}"
end
if params[:category] != nil
@category = params[:category]
if @store == "[Uncategorized]"
#Get all uncategorized products
else
category = Category.find(@category)
#Get the products from that category
end
end
@petros
petros / RestoreMSSQLDbWithANewName.sql
Created June 17, 2009 09:25
Restore an MSSQL backup to a different database name
RESTORE DATABASE MyNewDB
FROM DISK = 'D:\MyDB.bak'
WITH
MOVE 'MyDB_Data' TO 'C:\MSSQL\Data\MyNewDB_Data.MDF',
MOVE 'MyDB_Log' TO 'C:\MSSQL\Data\MyNewDB_Log.LDF',
REPLACE
GO
@petros
petros / gist:130224
Created June 15, 2009 17:18
Hello world in Flaming Thunder
Write "Hello world".
@petros
petros / HelloWorld.rb
Created June 15, 2009 17:16
Hello World in Ruby
puts "Hello world"
@petros
petros / CCNetConfigPart.xml
Created June 15, 2009 16:52
CC.NET Version control related settings
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="MyProject" queue="Q1" queuePriority="1">
<modificationDelaySeconds>0</modificationDelaySeconds>
<maxSourceControlRetries>15</maxSourceControlRetries>
<stopProjectOnReachingMaxSourceControlRetries>true</stopProjectOnReachingMaxSourceControlRetries>
<sourceControlErrorHandling>ReportOnRetryAmount</sourceControlErrorHandling>