Skip to content

Instantly share code, notes, and snippets.

View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
sayHello(){
alert ('Hello World');
}
}
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
articles: Ember.A([
Ember.Object.create({title:'title 1',status:'active'}),
Ember.Object.create({title:'title 2',status:'draft'}),
Ember.Object.create({title:'title 3',status:'draft'}),
Ember.Object.create({title:'title 4',status:'draft'}),
Ember.Object.create({title:'title 5',status:'active'}),
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
someArray: Ember.A([3,2,4,1]),
maxNumber: Ember.computed.max('someArray'),
newNumber: 5,
actions: {
insertNumber(){
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
sayHello(){
alert ("Hello");
}
}
View gist:cdc95f9d62f47a432a14881372c67ca8
ember new hello-world
cd hello-world
ember install ember-electron
ember electron
@eibrahim
eibrahim / examples.exs
Created Feb 2, 2016
Find the smallest element in a list
View examples.exs
def min [] do 0 end
def min [h|t] do _min [h|t],h end
defp _min [],smallest do smallest end
defp _min [h|t], smallest do
cond do
smallest <= h ->
_min t, smallest
smallest >= h ->
_min t, h
@eibrahim
eibrahim / examples.exs
Created Feb 2, 2016
Guess the number within a range
View examples.exs
defp midpoint a,b do div(a+b,2) end
def guess(my_choice, a.._) when my_choice == a do IO.puts "is it #{a}?" end
def guess(my_choice, _..b) when my_choice == b do IO.puts "is it #{b}?" end
def guess(my_choice, a.._) when my_choice < a do IO.puts "out of range" end
def guess(my_choice, _..b) when my_choice > b do IO.puts "out of range" end
def guess(my_choice, a..b) when my_choice > div((a+b),2) do
IO.puts "is it #{midpoint(a,b)}?"
guess my_choice, midpoint(a,b)..b
end
def guess(my_choice, a..b) when my_choice < div((a+b),2) do
@eibrahim
eibrahim / examples.exs
Created Feb 2, 2016
Greatest common denominator
View examples.exs
def gcd x,0 do x end
def gcd x,y do gcd y, rem(x,y) end
@eibrahim
eibrahim / examples.exs
Created Feb 2, 2016
Sum of integers from 1 to n
View examples.exs
def sum 1 do 1 end
def sum n do n + sum (n - 1) end
View examples.exs
def factorial 0 do 1 end
def factorial n do n * factorial(n-1) end
You can’t perform that action at this time.