Skip to content

Instantly share code, notes, and snippets.

import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@jpadilla
jpadilla / 01.md
Last active November 28, 2015 15:09
$ composer create-project laravel/laravel --prefer-dist filepreviews-laravel-example

Custom lookup types

By default django-filter uses Django's ORM built-in field lookups. If you want to globally accept specific lookups you can do the following:

from django_filters import filters


filters.LOOKUP_TYPES = ['gt', 'gte', 'lt', 'lte', 'custom_lookup_type']
@jpadilla
jpadilla / components.my-component.js
Last active April 21, 2023 17:14
Component Lifecycle Hooks
import Ember from 'ember';
export default Ember.Component.extend({
didInitAttrs(options) {
console.log('didInitAttrs', options);
},
didUpdateAttrs(options) {
console.log('didUpdateAttrs', options);
},
@jpadilla
jpadilla / usage.py
Last active March 19, 2020 15:46
Custom MethodFilter for django-filter
from django import forms
from django_filters import filters
filters.LOOKUP_TYPES = [
('', '---------'),
('exact', 'Is equal to'),
('not_exact', 'Is not equal to'),
('lt', 'Lesser than'),
('gt', 'Greater than'),
======================================================================
FAIL: test_ec_verify_should_return_false_if_signature_invalid (tests.test_algorithms.TestAlgorithms)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jpadilla/Projects/Personal/pyjwt/tests/test_algorithms.py", line 186, in test_ec_verify_should_return_false_if_signature_invalid
self.assertFalse(result)
AssertionError: True is not false
{
"id": "ad-test",
"image": "http://placehold.it/3000x2000",
"text": "Advertising",
"link": "http://barrandiando.com"
}
@jpadilla
jpadilla / hdn-dn.js
Created November 30, 2014 12:39
HDN Queries
db.posts.find({
source: 'designer_news',
createdAt: {
$gte: ISODate("2014-07-07T00:00:00Z"),
$lt: ISODate("2014-07-08T00:00:00Z")
}
}, {_id:0, __v: 0, createdAt:0, updatedAt:0}).sort({
points: -1,
comments: -1
}).limit(5)
@jpadilla
jpadilla / gist:be54c11376fd3175ef96
Last active August 29, 2015 14:10
Writing third party packages for Django REST Framework

Writing third party packages

Creating your package

You can use this cookiecutter template for creating reusable Django REST Framework packages quickly. Cookiecutter creates projects from project templates. While optional, this cookiecutter template includes best practices from Django REST framework and other packages, as well as a Travis CI configuration, Tox configuration, and a sane setup.py for easy PyPI registration/distribution.

Note: Let us know if you have an alternate cookiecuter package so we can also link to it.

Running the initial cookiecutter command