This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FacebookMiddleware(): | |
def process_request(self, request): | |
api_key = settings.FACEBOOK_API_KEY | |
secret_key = settings.FACEBOOK_SECRET_KEY | |
request.facebook = Facebook(api_key=api_key, secret_key=secret_key, request=request) | |
if request.facebook.is_logged_in(): | |
username = request.facebook.get_uid() | |
try: | |
curr_user = User.objects.get(username=username) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item(models.Model): | |
category = models.ForeignKey(Category, related_name='items') | |
city = models.ForeignKey(City, verbose_name=u'المنطقة', related_name='items') | |
activation_code = models.CharField(max_length=64) | |
is_active = models.BooleanField(default=False) | |
is_deleted = models.BooleanField(default=False) | |
email = models.EmailField(u'البريد الإلكتروني') | |
created_at = models.DateTimeField(auto_now_add=True) | |
updated_at = models.DateTimeField(auto_now=True) | |
title = models.CharField(u'العنوان', max_length=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% content_for(:calendar) do %> | |
<%= render 'calendar' %> | |
<% end %> | |
------------ | |
<% content_for(:calendar) { render :partial => 'calendar' } %> | |
------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# code in Blog model | |
########################## | |
feed.entries.each do |entry| | |
puts "=== creating new post..." | |
post = Post.new(:title => entry.title) | |
post.blog_id = self.id | |
puts "=== blog_id = #{post.blog_id}" | |
# code never reaches past Post.new line | |
# I have a datetime field (post_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePosts < ActiveRecord::Migration | |
def change | |
create_table :posts do |t| | |
t.references :blog, :null => false | |
t.datetime :post_date, :null => false | |
t.string :url, :null => false | |
t.string :author | |
t.string :title, :null => false | |
t.attachment :image, :null => false | |
t.text :body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BackgroundLayer | |
-(id) init { | |
self = [super init]; | |
if(self != nil) { | |
CCSprite *backgroundImage; | |
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { | |
backgroundImage = [CCSprite spriteWithFile:@"background.png"]; | |
} else { | |
backgroundImage = [CCSprite spriteWithFile:@"backgroundiPhone.png"]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# controller | |
def create | |
user = User.create(params[:user]) | |
respond_with(user, include: :extras) | |
end | |
# nginx conf | |
server { | |
listen 80; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def application(app, didReceiveLocalNotification: notification) | |
if app.applicationState == UIApplicationStateInactive | |
NSLog("didReceiveLocalNotification...") | |
url = NSURL.URLWithString("sms:12345678") | |
NSLog("finished creating URL...") | |
app.openURL(url) | |
NSLog("opened URL... Done.") | |
elsif app.applicationState == UIApplicationStateActive | |
App.alert(notification.alertBody) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Abdullahs-iMac-2:GM abdullah$ bundle update | |
Fetching gem metadata from https://rubygems.org/............ | |
Fetching version metadata from https://rubygems.org/... | |
Fetching dependency metadata from https://rubygems.org/.. | |
Resolving dependencies... | |
Using rake 10.4.2 | |
Using i18n 0.7.0 | |
Using json 1.8.3 | |
Using minitest 5.7.0 | |
Using thread_safe 0.3.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Scenario ONE | |
price = Decimal(33.000) # <-- passed in a number | |
factor = Decimal(0.3020) | |
price = price / factor | |
price = price * factor | |
price.quantize(Decimal("0.01"), rounding=ROUND_UP) # --> 33 | |
# Scenario TWO | |
price = Decimal('33.000') # <-- passed in a string | |
factor = Decimal('0.3020') |
OlderNewer