In urls.py
# urls like "articles/2011/tutorial03" or "articles/2011/tutorial03.html" or "articles/2011/tutorial03.htm"
urlpatterns = patterns('',
(r'articles/(?P<year>\d+)/(?P<item>[^/]+)(?:\.htm(?:l)?)?/?\$', 'articles.detail'),
)
| (function($) { | |
| $.fn.myPlugin = function(options, args){ | |
| this.each(function(){ | |
| $this = $(this); | |
| var instance = $this.data('myPlugin'); | |
| if (instance && typeof(instance) == 'object') | |
| callInstance(instance, options, args); | |
| else |
| <h2>{{ artist.name }}</h2> | |
| <div>{{ artist.bio }}</div> | |
| {% with_scope artist: artist._id %} | |
| {% assign comments = contents.comments %} | |
| {% if comments == empty %} |
| //Stupid "Schrodinger sort (cat not involved!)" based on http://dis.4chan.org/read/prog/1295544154 - great antipattern | |
| static void Main(string[] args) | |
| { | |
| int[] xs = new[] { 5, 3, 6, 3, 6, 3, 1, 4, 7}; | |
| var results = new ConcurrentQueue<int>(); | |
| Console.WriteLine("Sorted:"); | |
| Parallel.ForEach(xs, n => | |
| { | |
| Thread.SpinWait(n); //Thread.Sleep(n); |
| @implementation MySharedThing | |
| + (id)sharedInstance | |
| { | |
| DEFINE_SHARED_INSTANCE_USING_BLOCK(^{ | |
| return [[self alloc] init]; | |
| }); | |
| } | |
| @end |
I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.
It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.
In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.
| require 'spec_helper' | |
| describe FeaturePool do | |
| it "creates a new instance given valid attributes" do | |
| Fabricate :feature_pool | |
| end | |
| it "is not valid without a name" do | |
| Fabricate.build(:feature_pool, :name => "").should_not be_valid | |
| end |
| + (void) initialize | |
| { | |
| if ( self != [KBCommentEditorView class] ) | |
| return; | |
| // install the device-appropriate version of -layoutSubviews | |
| Method m1 = class_getInstanceMethod(self, @selector(layoutSubviews)); | |
| Method m2 = class_getInstanceMethod(self, IsPad() ? @selector(layoutSubviewsIPad) : @selector(layoutSubviewsIPhone)); | |
| method_exchangeImplementations(m1, m2); | |
| } |
| # ... | |
| gem 'carrierwave' | |
| gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL |
| // | |
| // UIDeviceHardware.h | |
| // | |
| // Used to determine EXACT version of device software is running on. | |
| #import <Foundation/Foundation.h> | |
| @interface UIDeviceHardware : NSObject | |
| - (NSString *) platform; |