Skip to content

Instantly share code, notes, and snippets.

View trmcnvn's full-sized avatar
✌️

Thomas McNiven trmcnvn

✌️
View GitHub Profile
@trmcnvn
trmcnvn / file.txt
Created May 24, 2017 21:46
Categories
Type
Looks
Exorcist
Digital Painting Studio
Poor
Salamander
Crinoline
Lion Books
Pottery
Lightning Magic
@trmcnvn
trmcnvn / application-adapter.js
Created December 22, 2016 10:44
Cancel in-flight ember-data requests
export default JSONAPIAdapter.extend({
init() {
this._super(...arguments);
this.xhrRequests = [];
},
ajaxOptions() {
const options = this._super(...arguments);
const defaultBeforeSend = options.beforeSend;
options.beforeSend = function(xhr) {
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
this.set('user', { name: 'vevix' });
}
});
import Ember from 'ember';
const LAZY_KEY = 'REQUEST_COMPONENT_TWO_LAZY';
export default Ember.Component.extend({
isLoading: true,
lazy: Ember.inject.service(),
init() {
this._super(...arguments);
@trmcnvn
trmcnvn / authenticator.js
Last active November 3, 2016 15:28
ember couchdb
import Base from 'ember-simple-auth/authenticators/base';
import { remote } from 'budget/adapters/application';
import RSVP from 'rsvp';
import run from 'ember-runloop';
import get from 'ember-metal/get';
export default Base.extend({
restore(data) {
return new RSVP.Promise((resolve, reject) => {
if (get(data, 'name')) {
-module(Game).
-export([check_anytrips/1, check_two_dice/3]).
check_anytrips(dice_roll) ->
value = num(uniq(dice_roll)),
value == 1.
check_two_dice(dice_roll, key, value) ->
lists:member(dice_roll, key) && lists:member(dice_roll, value).
@trmcnvn
trmcnvn / application.template.hbs
Created September 26, 2015 02:39
Routable Components
{{outlet}}
# Faster random records
module ActiveRecord
class Base
def self.random(limit = 1)
if (total = count) > 0
highest_possible_offset = [0, total - limit].max
offset = [rand(total), highest_possible_offset].min
num = [limit, total].min
offset(offset).limit(num)
else
function confirm() {
CustomEvent.observe(LiveEvents.LIVE_BEFORE_WINDOW_LOAD, function(win) {
if (win.toString() !== "LiveWindowChatFloating") return;
win.box.setToolbarCloseOnClick(function() {
var confirm = window.confirm("Are you sure?");
if (confirm !== false) {
CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_LEAVE_CHANNEL, this);
this.fire(LiveEvents.WINDOW_CLOSE);
}

Keybase proof

I hereby claim:

  • I am vevix on github.
  • I am vevix (https://keybase.io/vevix) on keybase.
  • I have a public key whose fingerprint is 5339 A16C 444A 97BC 032F 2380 8962 FE71 D808 7F83

To claim this, I am signing this object: