Skip to content

Instantly share code, notes, and snippets.

View alecklandgraf's full-sized avatar

Aleck Landgraf alecklandgraf

View GitHub Profile
@alecklandgraf
alecklandgraf / hello2.component.js
Last active June 28, 2016 01:13
hello3 component
module.component('helloNavFetch', {
controller: ['Me', function(Me) {
var ctrl = this;
this.$onInit = function () {
ctrl.loading = true;
Me.query().$promise.then(function (me) {
ctrl.me = me;
ctrl.loading = false;
});
};
@alecklandgraf
alecklandgraf / hello2.component.js
Last active June 28, 2016 01:01
hello2 component
module.component('helloNavFetch', {
controller: ['Me', function(Me) {
var ctrl = this;
this.$onInit = function () {
ctrl.loading = true;
Me.query().$promise.then(function (me) {
ctrl.me = me;
ctrl.loading = false;
});
};
@alecklandgraf
alecklandgraf / hello.route.js
Last active June 28, 2016 17:56
hello component route
module.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/hello', {
template: '<hello-nav me="$resolve.me"></hello-nav>',
resolve: {
'me': ['Me', function (Me) {
return Me.query().$promise;
}]
}
});
@alecklandgraf
alecklandgraf / hello.component.spec.js
Last active July 6, 2016 16:37
hello component test with component
describe("hello nav component", function(){
// globals set up and used in each test scenario
var $componentController;
beforeEach(module('app'));
beforeEach(inject(function(_$componentController_) {
$componentController = _$componentController_;
}));
@alecklandgraf
alecklandgraf / hello.component.spec.js
Created June 27, 2016 23:34
hello component test compile
describe("hello nav", function(){
// globals set up and used in each test scenario
var scope, element;
beforeEach(module('app'));
beforeEach(inject(function($rootScope, $compile) {
scope = $rootScope.$new();
element = angular.element('<hello-nav me="me"></hello-nav>');
element = $compile(element)(scope);
@alecklandgraf
alecklandgraf / hello.html
Created June 27, 2016 23:14
hello component html
<hello-nav me="{first_name: 'Aleck', last_name: 'Landgraf'}"></hello-nav>
@alecklandgraf
alecklandgraf / hello.component.js
Last active June 27, 2016 23:20
angular component hellp
module.component('helloNav', {
bindings: {
me: '<'
},
template: `<div class="section-nav">
<h2>Hello {{ $ctrl.me.first_name }} {{ $ctrl.me.last_name }}</h2>
</div>`
});
# This creates some bad audit_types
class AuditLog(models.Model):
LOG = 'lo',
NOTE = 'no',
AUDIT_CHOICES = (
(LOG, 'log'),
(NOTE, 'note',
)
audit_type = models.CharField(choices=audit_CHOICES)
@alecklandgraf
alecklandgraf / routes.clj
Created February 18, 2016 05:09
home-page
(defn home-page [request]
(let [flash (:flash request)]
(layout/render
"home.html"
(merge {:messages (db/get-messages)}
(select-keys flash [:name :message :errors])))) )
@alecklandgraf
alecklandgraf / good.py
Last active July 7, 2022 08:02
Python, the good parts
# string format with kwargs
user = {
'first_name': 'John',
'last_name': 'Doe',
'email': '[email protected]',
}
user_bio = '{first_name} is registered with email: {email}'.format(**user)
# string format with an object
class User(object):