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 / gist:110406
Created May 12, 2009 09:55
How to update the schema for an XPO object model
//How to update an XPO schema and create the XPObjectType table
using (Session session = new Session())
{
//Here we select one class from each assembly that contains XPO classes
//For example User is one of our XPO object model classes
Assembly[] array = { typeof(User).Assembly, typeof(XPObjectType).Assembly };
session.UpdateSchema(array);
}
@petros
petros / List-ForEach-method-instead-of-foreach.cs
Created June 12, 2009 13:50
Use List(T) ForEach method instead of foreach
//Use List(T) ForEach method
myList.ForEach(s => Console.WriteLine(s.ToString()));
//instead of:
foreach(var s in myList)
{
Console.WriteLine(s.ToString());
}
@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>
@petros
petros / HelloWorld.rb
Created June 15, 2009 17:16
Hello World in Ruby
puts "Hello world"
@petros
petros / gist:130224
Created June 15, 2009 17:18
Hello world in Flaming Thunder
Write "Hello world".
@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
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 / 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
@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 / 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