Skip to content

Instantly share code, notes, and snippets.

View typeoneerror's full-sized avatar
🤠
iOS, Capacitor, Ember, Vue, Rails

Benjamin Borowski typeoneerror

🤠
iOS, Capacitor, Ember, Vue, Rails
View GitHub Profile
GIT
remote: git://github.com/sporkrb/spork.git
revision: 224df492657e617a0c93c0319e78f0eefee5b636
specs:
spork (1.0.0rc4)
PATH
remote: engines/doki_core
specs:
doki_core (0.0.1)
@typeoneerror
typeoneerror / validated-input-component.js
Last active August 29, 2015 14:24
Input component that validates itself when ui actions happen
// pods/components/validated-input/component.js
import Ember from 'ember';
import Validators from 'doki/validators/all';
export default Ember.Component.extend({
validator: 'presence',
value: null,
// initializers/registrar.js
import Modals from 'doki/controllers/modals';
// TODO: this can't be right
export function initialize(registry, application) {
console.log('[5] Registrar::initialize');
application.register('controller:modals/add-resource-modal', Modals.AddResourceModal, { singleton: false });
application.register('controller:modals/confirm-class-delete-modal', Modals.ConfirmClassDeleteModal, { singleton: false });
import AuthenticatedRoute from 'doki/routes/authenticated';
export default AuthenticatedRoute.extend({
requireDean: false,
activate() {
this._super();
this.checkAccess();
},
// w/bind-attr
<div {{bind-attr class=":form-group model.validationErrors.name:has-error"}}>
// this works, but is there a short form?
<div class="form-group {{if model.validationErrors.name 'has-error'}}">
model(params) {
return Ember.RSVP.hash({
course: this.store.find('course', params.course_id),
topics: this.store.find('topic', { course_id: params.course_id })
});
},
setupController(controller, model) {
// when first called model will be { course: Class, topics: Class }
// next time entered, model will just be Class (just the value of "course" )
// router.js
this.route('parents');
this.route('parent', { path: 'parent/:parent_id' }, function() {
});
// parents
model() {
console.log('PARENTS');
return this.store.findAll('parent')
}
WebDeveloper.Information.displayFocusTarget = function(display, documents)
{
var contentDocument = null;
var bodyDocument = null;
var elements = null;
var focusables = 'a[href], *[tabindex], area, button, iframe, input, select, textarea';
for(var i = 0, l = documents.length; i < l; i++)
{
contentDocument = documents[i];
@typeoneerror
typeoneerror / first_or_initalize.rb
Last active August 29, 2015 14:20
first_or_initialize_wtf
# Does not work
progress = DokiCore::Progress.where(user: user, course: course)
.first_or_initialize(progressable: progressable)
puts progress.valid? # false
puts progress.errors.to_a # ['course is blank', 'user is blank']
pp progress # { course_id: 1, user_id: 1 } <<------- WTF!
# Works
progress = DokiCore::Progress.where(user: user, course: course).first
{
"settings": {
"todoreview": {
"case_sensitive": true,
"patterns": {
"HIGH": "HIGH[\\s]*?:[\\s]*(?P<high>.*)$",
"TODO": "TODO[\\s]*?:[\\s]*(?P<todo>.*)$",
"NOTE": "NOTE[\\s]*?:[\\s]*(?P<note>.*)$",
"FIXME": "FIX ?ME[\\s]*?:[\\s]*(?P<fixme>.*)$",
"CHANGED": "CHANGED[\\s]*?:[\\s]*(?P<changed>.*)$"