Skip to content

Instantly share code, notes, and snippets.

@ksin
ksin / controllers.application.js
Created February 19, 2019 18:19
Null and undefined in hbs
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
nullProperty: null,
undefinedProperty: undefined
});
import Ember from 'ember';
import { moduleForComponent } from 'ember-qunit';
export default function (name, options={}) {
moduleForComponent(name, {
integration: true,
setup() {
this.select = function (from, text) {
let $el = this.$(from);
let $option = $el.find(`option:contains(${text})`);
@ksin
ksin / components.alert-pow.js
Last active October 15, 2015 17:38
Twiddle to see if overriding .on works
import Ember from 'ember';
export default Ember.Component.extend({
powPow: function() {
alert('POW POW POW!!!');
}.on('didInsertElement')
});
#Cookies & Ovens
#Oven
#-on, off -empty, full
#-temperature -how many cookies it has?
#-store cookies in it. making instances of Cookie and passing them into Oven
#oven has many cookies
#Cookie
#-doughy, baked, burnt
module Numbers
WEIRD = {
0 => "zero",
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
module Roman
MAP = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
40 => "XL",
# Convert an integer into its English equivalent.
def in_words(int)
# Your glorious code here
end
### Test code
in_words(4) # => "four"
in_words(27) # => "twenty seven"
in_words(102) # => "one hundred two"
def to_roman(num)
results = ""
if num % 5 == 4
if num > 5
results = "IX"
else
results = "IV"
end
elsif num == 5
@ksin
ksin / copy_attachments.rb
Last active February 13, 2017 19:59
Paperclip copy attachments s3
### s3 implementation of Paperclip module that supports deep
### cloning of objects by copying image attachments.
### Refer to Paperclip issue: https://github.com/thoughtbot/paperclip/issues/1361#issuecomment-39684643
### Original gist works with fog: https://gist.github.com/stereoscott/10011887
module Paperclip
module CopyAttachments
def copy_attachments_from(source_obj, source_bucket = nil, destination_bucket = nil)
self.class.attachment_definitions.keys.each do |attachment_name|
source_attachment = source_obj.send(attachment_name)
@ksin
ksin / instagram-json.js
Created November 23, 2014 02:57
JSON fixture
export var yoloInstagramRecentMediaJson = {"pagination":{"next_max_tag_id":"1414697845333930","deprecation_warning":"next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead","next_max_id":"1414697845333930","next_min_id":"1414697900707568","min_tag_id":"1414697900707568","next_url":"https:\/\/api.instagram.com\/v1\/tags\/yolo\/media\/recent?count=16\u0026callback=jQuery1111011989749874919653_1414697864571\u0026client_id=c9be10c8dce447049b4f6939d2532caf\u0026max_tag_id=1414697845333930\u0026_=1414697864572"},"meta":{"code":200},"data":[{"attribution":null,"tags":["beautiful","life","old","bestie","yolo","school","days","laugh","love","times","miss","perfect","forever","lame","friends","make","up","amazing","live","wonderful","cutie","adorable"],"location":null,"comments":{"count":0,"data":[]},"filter":"Normal","created_time":"1414697900","link":"http:\/\/instagram.com\/p\/uyeWEJQ9SB\/","likes":{"count":0,"data":[]},"images":{"low_resolution":{"url":"http:\/\/scontent-b.cd