This file contains hidden or 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
(function() { | |
"use strict"; | |
var FooModel = Backbone.Model.extend({ | |
defaults: { | |
bar: '', | |
baz: 444 | |
}, | |
validate: function(attrs) { |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<style> | |
.body { | |
perspective: 100; | |
} |
This file contains hidden or 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
module CheckedAttributes | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def attr_checked(attribute, &block) | |
setter_method_name = (attribute.to_s + '=').to_sym | |
old_method_name = (attribute.to_s + '_old').to_sym |
This file contains hidden or 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
// don't forget to compile with -lm option | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <math.h> | |
#include <ctype.h> | |
// Generic Linked List implementation below thanks to pseudomuto |
This file contains hidden or 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
require_relative 'tasks_service' | |
describe TasksService do | |
it 'works' do | |
s = TasksService.new | |
expect(s).to receive(:p).with('begin transaction') | |
expect(s).to receive(:p).with('end transaction') | |
expect(s).to receive(:p).with('ensuring') | |
expect(s.create_task).to eq('mytask created') |
This file contains hidden or 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
# far far from perfect yet a bazillion times more elegant than java | |
class TasksService | |
def initialize | |
@entity_manager_service = Object.new | |
end | |
def work_safe | |
entity_manager = @entity_manager_service # dot something | |
begin |
This file contains hidden or 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
# in settings.py | |
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
EMAIL_USE_TLS = True | |
EMAIL_HOST = 'smtp.gmail.com' | |
EMAIL_PORT = 587 | |
EMAIL_HOST_USER = '[email protected]' | |
EMAIL_HOST_PASSWORD = '...' |
This file contains hidden or 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
from django.conf import settings | |
from django.conf.urls.defaults import * | |
from django.contrib import admin | |
admin.autodiscover() | |
def if_installed(appname, *args, **kwargs): | |
ret = url(*args, **kwargs) | |
if appname not in settings.INSTALLED_APPS: | |
ret.resolve = lambda *args: None |
This file contains hidden or 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
from django.contrib import admin | |
from django.shortcuts import render | |
from ... import MyModel | |
class MyModelAdmin(admin.ModelAdmin): | |
... | |
def get_urls(self): | |
urls = super(MyModelAdmin, self).get_urls() |
This file contains hidden or 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 Player: | |
def get_rect(self): | |
return Rect(0,0,100,100) | |
if player.get_rect().colliderect(obstacle.get_rect()): | |
print("COLLISION!") |