Skip to content

Instantly share code, notes, and snippets.

View federicobucchi's full-sized avatar
:octocat:
Coding

Federico Bucchi federicobucchi

:octocat:
Coding
View GitHub Profile
<h5>application-loading template</h5>
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
purchases: Ember.computed.alias('model.purchase')
});
@federicobucchi
federicobucchi / 0_reuse_code.js
Created August 26, 2016 20:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@federicobucchi
federicobucchi / tic-tac-toe.js
Created September 9, 2015 21:23
Tic Tac Toe game
(function() {
var player1 = new player('Federico', 'Bucchi', 'X');
var player2 = new player('Mac', 'BookPro', 'O');
var wins = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[1, 4, 7],
[2, 5, 8],
[3, 6, 9],
Verifying I am +federicobucchi on my passcard. https://onename.com/federicobucchi
var test1 = { 30: 'Template A', 60: 'Template B', 10: 'Template C' };
var test2 = { 30: 'Template A', 70: 'Template B' };
var test3 = { 'A': 50, 'B': 50 };
function selectEnv(templates) {
var newTemplates = {};
var tot = 100;
var random = Math.floor(Math.random() * 100);
var i;
@federicobucchi
federicobucchi / isValidCreditCard.js
Last active August 29, 2015 14:21
Luhn Algorithm - Credit Card Validation
var isValidCreditCard = function (card) {
// Array I want to use to keep the transformed digits
var momentaryCard = [];
// Sum of transformed digits
var sum = 0;
// Card length
var cardLength = card.length;
@federicobucchi
federicobucchi / primes.js
Created May 12, 2015 19:43
Count the number of prime numbers less than a non-negative number
var countPrimes = function(n) {
var counter = 0;
var input = n - 1;
var isPrime = function(input) {
var square;
if (isNaN(input) || !isFinite(input) || input % 1 || input < 2) {
return false;
@federicobucchi
federicobucchi / happy_number.js
Last active August 29, 2015 14:20
Happy Number
var isHappy = function(n) {
var arr = n.toString().split('');
var times = 0;
var exp;
var scan = function(arr) {
exp = 0;
times += 1;
var arr = ['f', 'e', 'd']
var lazy = (function(){
var counter = 0;
return function(){
console.log(arr[counter]);
counter += 1;