Skip to content

Instantly share code, notes, and snippets.

View timmyomahony's full-sized avatar

Timmy O'Mahony timmyomahony

View GitHub Profile
@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',
@poteto
poteto / controllers.application.js
Last active August 22, 2023 04:29
ember-changeset-validations demo
import Ember from 'ember';
import AdultValidations from '../validations/adult';
import ChildValidations from '../validations/child';
import { reservedEmails } from '../validators/uniqueness';
import { schema } from '../models/user';
const { get } = Ember;
const { keys } = Object;
export default Ember.Controller.extend({
@timmyomahony
timmyomahony / twittify.py
Created June 13, 2011 16:42
twittify: django template filter to replace metions (@'s) and hashtags (#'s) with links to twitter
@register.filter(name='twittify')
def twittify(value):
""" Replace @ and #'s with links to twitter"""
return mark_safe(
re.sub(r"#(?P<ht>([a-zA-Z0-9_])+)", r"#<a href='http://twitter.com/#!/search?q=\g<ht>' target='_blank'>\g<ht></a>",
re.sub(r"@(?P<un>([a-zA-Z0-9_]){1,15})", r"@<a href='http://twitter.com/\g<un>' target='_blank'>\g<un></a>", value))
)
twittify.mark_safe=True