Skip to content

Instantly share code, notes, and snippets.

@exit99
exit99 / Ajax-Angular-Django
Last active August 29, 2015 14:06
How to send ajax calls with angular via Django
Angular
=======
var myApp = angular.module('myApp', []);
function serializeData( data ) {
if ( ! angular.isObject( data ) ) {
return( ( data == null ) ? "" : data.toString() );
}
@exit99
exit99 / gist:b7bb116edabf5e301db1
Created October 6, 2014 15:16
Basic Angular Directive
qaApp.directive('qaAction', function () {
return {
restrict: 'E',
scope: {title: '@'},
template: '<span style="color:blue">{$ action $}</span><br><br>',
scope: {
'action': '='
}
}
});
@exit99
exit99 / Basic Angular Directive
Last active August 29, 2015 14:07
Using a directive template
qaApp.directive('qaAction', function () {
return {
restrict: 'E',
scope: {title: '@'},
templateUrl: "action.html",
scope: {
'action': '='
},
controller: function ($http, $scope, $rootScope) {
}
@exit99
exit99 / OOP style directive controllers for Angular
Last active August 29, 2015 14:08
How to make base directive controllers that can be inherited in Angular.js
app.directive('upgrade1', function () {
return {
restrict: 'E',
templateUrl: "my_template.html",
scope: {
'info': '=info',
},
controller: 'upgrade1',
}
});
@exit99
exit99 / Using Python-SwiftClient
Created October 31, 2014 13:37
How to use the python swift client.
# Create a new user with permissions
1. Get the `super_admin_key` from `/etc/swift/proxy-server.conf`
2. Make sure your admin is working:
:::bash
swift -A https://<url>:8080/auth/v1.0 -U ADMIN_ACCOUNT:ADMIN_USER -K ADMIN_PASSWORD stat -v --insecure
(function () {
window.app = angular.module('app', []);
}).call(this);
@exit99
exit99 / Auto-Dave
Last active March 1, 2016 19:35
Automating Dave's Job
import time
import urllib2
from datetime import datetime
def do_dave():
while 10 < datetime.now().hour < 15:
time.sleep(5)
urllib2.urlopen('http://www.reddit.com/')
import ast
from django.db import models
class ListField(models.TextField):
__metaclass__ = models.SubfieldBase
description = "Stores a python list"
# We use this to store user pks on flags.
def __init__(self, *args, **kwargs):
qaApp.filter('safe', function ($sce) {
return function (value) {
return $sce.trustAsHtml(value);
};
});
qaApp.filter('nl2br', function() {
return function(data) {
if (!data) return data;
return data.replace(/\n\r?/g, '<br />');
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system