Skip to content

Instantly share code, notes, and snippets.

View tylerjohnst's full-sized avatar
:fishsticks:

Tyler Johnston tylerjohnst

:fishsticks:
  • GitHub Staff
  • Saint Petersburg, FL
View GitHub Profile
moduleFor('controller:application', 'Application controller');
test('it has access to the currentUser object', function() {
var controller = this.subject();
Ember.run(function() {
var user = controller.get('currentUser');
ok(user, "User should exist but doesn't");
});
});
App.WidgetRoute = Ember.Route.extend({
model: function(params) {
return Ember.RSVP.hash({
widget: this.store.find('widget' params.id),
cogs: App.MyCustomAjax()
})
},
setupController: function (controller, rsvp) {
controller.set('model', rsvp.widget);
App.PaginationMixin = Ember.Mixin.create({
// Define a property called "paginate" that returns the collection to paginate.
currentPage: 0,
perPage: 15,
collectionSize: Ember.computed.alias('paginate.length'),
actions: {
setPage: function(pageNumber) {
window.I18n = {
pushDictionary: function(translations) {
I18n.translations = Ember.Object.create(translations);
},
t: function(key, opts) {
var translation = I18n.translations.get('en.' + key);
opts = opts || {};
@tylerjohnst
tylerjohnst / phonegap_back_button_mixin.js
Created August 25, 2014 13:56
Ember bindings for using phonegap events
App.PhonegapBackbuttonMixin = Ember.Mixin.create({
activate: function () {
this.get('phonegapProxy').on('backbutton', this, this.goBack);
},
deactivate: function() {
this.get('phonegapProxy').off('backbutton', this, this.goBack);
},
});
@tylerjohnst
tylerjohnst / one.clj
Last active August 29, 2015 14:06
Project Euler #1
(ns problems.one)
(defn- multiple-of [num x] (zero? (mod x num)))
(defn- multiples-of-three-and-five [x]
(or (multiple-of 3 x)
(multiple-of 5 x)))
(defn- real-numbers-below [x] (range 1 x))
(defn multiples-of-three-and-five-below [x]
class Foo
def self.foo=(value)
@foo = value
end
def self.foo
@foo
end
end
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FRP Infinite Scroll using Bacon.js</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.53/Bacon.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.7.0/lodash.min.js"></script>
<style type="text/css">
body {
@tylerjohnst
tylerjohnst / select.scss
Last active August 29, 2015 14:21
Modern browser compatible select styling with bootstrap 3
select.form-control {
-webkit-appearance: none;
-moz-appearance: none;
background-color: #fff;
background-image: url("select.png");
background-repeat: no-repeat;
background-position: right center;
padding-right: 30px;
&:-moz-focusring {