Skip to content

Instantly share code, notes, and snippets.

@eupharis
eupharis / django_test_sqlite3.py
Last active December 27, 2015 15:09
faster django tests
if 'test' in sys.argv:
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
@eupharis
eupharis / django_template_datetime_in_code.py
Created October 23, 2013 23:05
A nice way to get Python strings to be that nice default Django template datetime format.
from django.template import defaultfilters
from django.utils import timezone
localtime = timezone.template_localtime(my_date)
template_style_date = defaultfilters.date(localtime, settings.DATETIME_FORMAT)
# settings.DATETIME_FORMAT is the Django default by default, but can be overwritten in your settings.py
@eupharis
eupharis / rootscope_in_run.js
Last active December 24, 2015 10:59
Angular $rootScope in run method
var renderer2 = angular.module('pak', ['pak.filters', 'pak.services',...]);
renderer2.run(['$rootScope', function($rootScope) {
$rootScope.some_function = function() {
console.log('HELLO WORLD!!!!');
};
// function is available in all CHILD SCOPES
}]);
@eupharis
eupharis / accordion-icon-switch.js
Last active December 24, 2015 02:59
Bootstrap Accordion Icon Switch
/*
Updates An Accordion's Icon.
Just include:
<span class="accordion-icon">+</span>
To your accordion-toggle!
*/
"use strict";
$(function() {
#!/bin/bash
grep -ri $1 $2 --exclude-dir={lib,css,stylesheets} --exclude=*{app.min.js,app.js,templates.js} --color
@eupharis
eupharis / droppable_directive.html
Last active December 21, 2015 11:59
groups idea
<div ng-repeat="group in groups">
<div data-group={{group.id}} group-droppable>{{group.name}}</div>
<div ng-repeat="pak in paks" draggable>
<!-- ... pak display -->
</div>
</div>
<script>
<!-- angular directive boilerplate -->
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<script src="http://code.angularjs.org/angular.js"></script>
<body>
<div id="angular-free">
I am a completely inert {{double-curly}}. Angular can't touch this!
Free to do whatever jQuery craziness strikes your fancy.
Or hell, add a backbone app here.
</div>
<!-- don't add ng-app="angular-app" - that's what kicks off auto-bootstrapping!!! -->
watch: {
scripts: {
files: [js + '/**/*.js'],
tasks: ['concat:js'],
},
handlebars: {
files: ['templates/**/*.hbs'],
tasks: ['handlebars'],
},
css: {
# where user_roles is an array filled with strings
# option's value and text will both be role
<select ng-model="selectedUser.role" ng-options="role for role in user_roles">
</select>
# where supported_languages is an array filled with objects
# option's value will be language.code and option's text will be language.label
<select ng-model="selectedUser.language_code"
<!--[if lte IE 8]>
{% if DEVELOPMENT %}
<script type="text/javascript" src="https://getfirebug.com/releases/lite/1.3/firebug-lite.js"></script>
{% endif %}
<![endif]-->