Skip to content

Instantly share code, notes, and snippets.

@chancancode
chancancode / application.template.hbs
Last active September 8, 2015 23:05
<link-supressor>
<link-supressor pattern="(facebook|twitter)" message="Get back to work!">
<ul>
<li>Not censored: <a href="http://emberjs.com">http://emberjs.com</a></li>
<li>Censored: <a href="http://facebook.com">http://facebook.com</a></li>
<li>Censored: <a href="http://twitter.com">http://twitter.com</a></li>
<li>Not censored: <a href="http://wikipedia.org">http://wikipedia.org</a></li>
</ul>
</link-supressor>
@chancancode
chancancode / application.template.hbs
Created September 9, 2015 00:51
<expandable-content> (improved)
<expandable-content>
<p>Lorem ipsum dolor sit amet, eu reque aperiam vix. Vel cu albucius cotidieque, ut mel admodum vivendo. Paulo populo vivendo vix in, vix malorum dignissim et, te simul libris persecuti sea. Ut conceptam consectetuer vel, civibus patrioque per no, no habemus commune argumentum vim. Ius in etiam choro iuvaret, pro accusata periculis dissentiunt ea. Pri te nobis phaedrum, in nihil molestie pro.</p>
<p>Novum efficiendi eu ius. Mea id fuisset verterem, eu eum ipsum democritum. Suas ullum pro ut, mei ex elit explicari. Te vero delicata mea. Graeci discere pro ex, illum habemus vivendum est et. Iisque aperiri ea mel. Eu malis dolorem usu.</p>
<p>Ut eos eloquentiam definitionem, ad quem libris bonorum ius. Explicari consequat ex duo, dolores honestatis eu pro, dictas persius mel eu. Vidit graece quaeque ut vel, qui magna dolorum ne, pro volumus expetenda cu. Et sed quaeque accumsan, cum ei alienum accusamus.</p>
<p>Dicta saperet perfecto usu cu. Assueverit dissentias no eum. Nec ex du
<x-input /> &lt;&mdash; this should be checked
@chancancode
chancancode / application.template.hbs
Last active September 11, 2015 19:23
New Twiddle
<h1>Toggle Button Demo</h1>
<p>On: <toggle-button active={{true}} /></p>
<p>Off: <toggle-button active={{false}} /></p>
<p>Disabled: <toggle-button disabled={{true}} /></p>
@chancancode
chancancode / application.controller.js
Last active September 15, 2015 10:18
<toggle-button>
import Ember from 'ember';
export default Ember.Controller.extend({
airplaneMode: false,
wifi: true,
bluetooth: true,
actions: {
setAirplaneMode(value) {
if (value) {
# This is what I wanted to do...
class MyObject < SomeSuperClass
include SomeWebService::DataSource
data_source_id '123456' # data_source_id() is a class method added by the module
def initialize(name)
@name = name
end
# This is what I wanted to do...
class MyObject < SomeSuperClass
@@data_source_id = '123456'
@@data = nil
def initialize(name)
@name = name
end
@chancancode
chancancode / gist:1744108
Created February 5, 2012 08:34
Road Removal
Road Removal
https://www.facebook.com/hackercup/problems.php?pid=278355025564990&round=154897681286317
You are given a network with N cities and M bidirectional roads connecting these cities. The
first K cities are important. You need to remove the minimum number of roads such that in the
remaining network there are no cycles that contain important cities. A cycle is a sequence of
at least three different cities such that each pair of neighboring cities are connected by a
road and the first and the last city in the sequence are also connected by a road.
@chancancode
chancancode / gist:1744262
Created February 5, 2012 09:04
Monopoly
Monopoly
https://www.facebook.com/hackercup/problems.php?pid=299871816717968&round=154897681286317
In a certain business sector there are currently N small companies, each having just a single
employee. These employees are numbered 1 through N.
The business sector is about to be transformed into a monopoly. This will happen through a
series of mergers, until there is only one company. A single merger involves two companies.
In a merger, the president of one company becomes the direct report of the president of the
@chancancode
chancancode / gist:1744276
Created February 5, 2012 09:07
Sequence Slicing
Sequence Slicing
https://www.facebook.com/hackercup/problems.php?pid=317343604974808&round=154897681286317
Let S be a sequence of N natural numbers. We can define an infinite sequence MS in the
following way: MS[k] = S[k mod N] + N * floor(k / N). Where k is a zero based index.
For example if the sequence S is {2, 1, 3} then MS would be {2, 1, 3, 5, 4, 6, 8, 7, 9,
11, 10, 12...}