Skip to content

Instantly share code, notes, and snippets.

@brianally
brianally / authenticators-admin.js
Created July 2, 2015 18:18
Ember Simple-Auth authenticator for handling manual login and getting OAuth token back from server.
// app/authenticators/admin.js
import Ember from "ember";
import Base from "simple-auth/authenticators/base";
import ENV from "../config/environment";
export default Base.extend({
// called by login form action
// this.get("session").authenticate("authenticator:admin", credentials).then(...)
@brianally
brianally / routes-login.js
Created July 2, 2015 18:33
Ember route showing both OAuth2 and manual login
// app/routes/login.js
import Ember from "ember";
import ENV from "../config/environment";
export default Ember.Route.extend({
setupController: function(controller, model) {
controller.set("errorMessage", null);
},
actions: {
@brianally
brianally / gist:740b06b1ee6e2a54edec
Created July 2, 2015 18:41
Set a class on body if Ember app is embedded in iframe, so as to hide certain elements and/or take/suppress other actions.
// config/environment.js
module.exports = function(environment) {
var ENV = {
// ...
APP: {
inIframe: false
}
@brianally
brianally / filter-controller-or-whatever.js
Last active August 29, 2015 14:24
Multiple filters for Ember-Data
// some controller
import Ember from 'ember';
export default Ember.Controller.extend({
responses : [],
filteredResponses: [],
sectors : [],
dateFrom : null,
dateTo : null,
@brianally
brianally / embed-link.js
Created July 2, 2015 19:11
Ember.js embed link widget
@brianally
brianally / UserShell.php
Last active August 29, 2015 14:24
Simple CakePHP2.x user shell for use with ACL roles
<?php
// see User model at:
// https://gist.github.com/brianally/f4f70f5bb8c0f2304307
App::uses('AppShell', 'Console/Command');
class UserShell extends AppShell {
public $uses = array('User');
@brianally
brianally / User.php
Created July 2, 2015 20:16
CakePHP 2.x User model for use with Role ACL
<?php
App::uses('AppModel', 'Model');
App::uses('SimplePasswordHasher', 'Controller/Component/Auth');
class User extends AppModel {
public $actsAs = [
'Acl' => ['type' => 'requester']
];
@brianally
brianally / PageSlugRoute.php
Created July 2, 2015 20:27
Dynamic pages with slugs for CakePHP 2.x
<?php
// app/Lib/Routing/Route/PageSlugRoute.php
//
App::uses('Page', 'Model');
App::uses('CakeRoute', 'Routing/Route');
class PageSlugRoute extends CakeRoute {
public function parse($url) {
$params = parent::parse($url);
if (empty($params)) return false;
@brianally
brianally / Category.php
Created July 2, 2015 20:41
Hierarchical categories using MPTT with CakePHP 2.x
<?php
class Category extends AppModel {
public $hasAndBelongsToMany = [
'Item' => [
'className' => 'Item',
'with' => 'CategoryItem',
'foreignKey' => 'category_id',
'associationForeignKey' => 'item_id'
]
@brianally
brianally / Air_Emissions_-_SOx.xls
Last active February 11, 2019 07:06
Zoom Radius Adjust
NPRI Number Facility Name Company Name Province City Address Postal Code Rural Address NAICS Name NAICS Data Link 2013 NOx Emissions (t) 2013 SOx Emissions (t) 2013 VOC Emissions (t) 2013 PM2.5 Emissions (t) 2013 PM10 Emissions (t) 2013 TPM Emissions (t) 2013 NH3 Emissions (t) 2013 CO Emissions (t) NPRI Data Link NAICS2 NAICS3 NAICS4 NAICS6 Latitude Longitude
0000003758 Hanlan Robb Gas Plant Direct Energy Marketing Ltd. Alberta Edson PO Box 6480 Road East T7E1T8 0 124.04 2182.45 9.97 2.02 2.02 -99.00 -99.00 74.63 http://www.ec.gc.ca/inrp-npri/donnees-data/index.cfm?do=facility_substance_summary&lang=En&opt_npri_id=0000003758&opt_report_year=2013 53.20450000 -116.81120000
0000015596 Marten Hills 12-18-76-25w4 Canadian Natural Resources Limited Alberta N/A 0 21.90 26.16 -99.00 1.03 1.03 -99.00 -99.00 -99.00 http://www.ec.gc.ca/inrp-npri/donnees-data/index.cfm?do=facility_substance_summary&lang=En&opt_npri_id=0000015596&opt_report_year=2013 55.58560000 -117.89160000
0000019534 Wapiti 12-03 Devon C