Skip to content

Instantly share code, notes, and snippets.

View mafis's full-sized avatar
🏠
Working from home

Maximilian Fischer mafis

🏠
Working from home
View GitHub Profile
public static List<string> GetAlphabet()
{
List<string> alphabet = new List<string>();
for (int intCount = 65; intCount <= 90; intCount++)
alphabet.Add(((char)intCount).ToString());
return alphabet;
}
#Einfach am Anfang eines Controllers hinzufügen und
#dann kann auf die Methoden nur Zugriffen werden, wenn
#man eingeloggt sind, funktioniert natürlich auch mit :only & :except
before_filter :authenticate_user!
#Gibt zurück ob jemand eingeloggt ist
user_signed_in?
#Gibt den aktuellen eingeloggten Benutzer zurück
current_user
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_us
@mafis
mafis / SelectionColor.m
Created March 30, 2011 08:42
Selection Color in Objective-C
//View erstellen
UIView *bgColorView = [[UIView alloc] init];
//View anpassen, wie er aussehen soll
[bgColorView setBackgroundColor:[UIColor orangeColor]];
//Den View als SelectBackgroundView der Cell setzten
[cell setSelectedBackgroundView:bgColorView];
//View wieder freigeben
@mafis
mafis / SelectionColor.cs
Created March 30, 2011 08:40
In Monotouch
//View erstellen
UIView view = new UIView();
//View anpassen, wie er aussehen soll
view.BackgroundColor = UIColor.Orange;
//Den View als SelectBackgroundView der Cell setzten
cell.SelectedBackgroundView = view;
using (StreamWriter writer = new StreamWriter("Meine Txt.txt"))
{
writer.Write("Etwas schreiben ");
writer.WriteLine("Etwas in einer neuen Zeile schreiben");
writer.WriteLine("Noch etwas in einer neuen Zeile schreiben");
}
Factory.sequence :email do |n|
"email#{n}@factory.com"
end
Factory.define :user do |a|
a.email { Factory.next(:email)}
a.password "1234567890"
end
Failure/Error: @account = Factory(:account)
ActiveRecord::RecordInvalid:
Validation failed: Name already used, Name already used
before(:each) do
Account.destroy_all
@account = Factory(:account)
end
@mafis
mafis / UINavigationBar Custom Control.cs
Created March 27, 2011 19:47
UINavigationBar Custom Control
using System;
using MonoTouch.UIKit;
using System.Drawing;
using MonoTouch.Foundation;
namespace CustomControls
{
[MonoTouch.Foundation.Register("CustomNavigationBar")]
public class CustomNavigationBar : UINavigationBar
{