Skip to content

Instantly share code, notes, and snippets.

View timmyomahony's full-sized avatar

Timmy O'Mahony timmyomahony

View GitHub Profile
@timmyomahony
timmyomahony / widget.py
Created January 20, 2020 12:02
Example MathJax with Django Pagedown
from pagedown.widget import PagedownWidget
from django import forms
from django.contrib.admin import widgets
class MathJaxAdminPagedownWidget(PagedownWidget, widgets.AdminTextareaWidget):
class Media:
css = {
'all': ('pagedown/demo/browser/demo.css',
@timmyomahony
timmyomahony / api.js
Last active January 19, 2020 18:26
An Ember Ajax service that works with Ember Simple Auth
// see https://timmyomahony.com/blog/ember-ajax-and-ember-simple-auth/
import AjaxService from 'ember-ajax/services/ajax';
import ENV from 'connected-insight/config/environment';
import {inject as service} from '@ember/service';
import {computed} from '@ember/object';
export default AjaxService.extend({
session: service(),
host: ENV.serverHost,
authorizer: 'authorizer:token',
@timmyomahony
timmyomahony / controller.js
Created February 26, 2018 20:20
Example Angular form
$scope.submitForm = function(isValid) {
if ($scope.userForm.$valid) {
alert('Thank you for registering');
location.reload();
} else {
alert('Error registering');
}
}
@timmyomahony
timmyomahony / app.py
Last active December 5, 2017 12:43
Getting Flask and MySQL set up
from flask import Flask, jsonify
from flask_mysqldb import MySQL
app = Flask(__name__)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'testtest1234'
app.config['MYSQL_DB'] = 'test_db'
mysql = MySQL(app)
var UK = d3.locale({
"decimal": ".",
"thousands": ",",
"grouping": [3],
"currency": ["£", ""],
"dateTime": "%a %b %e %X %Y",
"date": "%m/%d/%Y",
"time": "%H:%M:%S",
"periods": ["AM", "PM"],
"days": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
@timmyomahony
timmyomahony / readme.md
Last active November 23, 2018 17:49
Making Ember addons FastBoot 1.0 compatible

Converting addons to Fastboot v1.0

Fastboot is currently transitioning to version 1.0 which introduces some breaking changes. The most pressing issue is that the approach previously suggested for handling dependencies in addons has changed.

This post has a bit of background of how Ember CLI and addons work followed by some details on how to migrate addons to the new Fastboot v1.0 structure.

How dependencies are manager for Ember projects (not addons)

TODO: basic package.json, bower.json, ember install and ember-cli-build.js/app.import

@timmyomahony
timmyomahony / controllers.application.js
Created April 20, 2017 15:37
Query Params from setupController
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@timmyomahony
timmyomahony / javscript-data-structures-and-control-challenge.markdown
Created January 15, 2017 14:00
Javscript data structures and control challenge

Javscript data structures and control challenge

This is from the challenge at the end of the the "javascript data structures and control" section of stream 1

A Pen by Timmy on CodePen.

License.

@timmyomahony
timmyomahony / components.slide-list-item.js
Last active July 18, 2016 11:11
Telling your parents you've rendered
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'li',
classNames: ['slide-list__list__item'],
didInsertElement() {
this._super(...arguments);
this.get('childRendered')();
}
});
import Ember from 'ember';
export default Ember.Component.extend({
tagName: "section",
page: 1,
paginateBy: 10,
paginatedItems: Ember.computed('amenities', 'page', function(){
var i = (parseInt(this.get('page')) - 1) * parseInt(this.get('paginateBy'));
var j = i + parseInt(this.get('paginateBy'));
return this.get('items').slice(i, j);