Skip to content

Instantly share code, notes, and snippets.

View jamesxv7's full-sized avatar
🔬
Researching

Jaime Olmo jamesxv7

🔬
Researching
View GitHub Profile
@jamesxv7
jamesxv7 / fibonacci.js
Last active January 15, 2016 20:42
The Fibonacci Sequence
/**
* 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
* The next number is found by adding up the two numbers before it.
* - The 2 is found by adding the two numbers before it (1+1)
* - Similarly, the 3 is found by adding the two numbers before it (1+2),
* - And the 5 is (2+3), and so on
*/
// Using recursion
function fibonacciNumberOf(number) {
@jamesxv7
jamesxv7 / nice-gradient.css
Created February 12, 2016 15:42
Nice gradient using CSS
div {
height: 100px;
background-color: red;
background-image:
linear-gradient(
45deg,
#7BB9CF,
#848DD0,
#AC01CC,
#CD00A9,
@jamesxv7
jamesxv7 / index.html
Created February 24, 2016 13:49
HTML Template
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="css/normalize.min.css">
@jamesxv7
jamesxv7 / stickyfooter.css
Created February 24, 2016 15:17
Sticky footer using CSS
* {
margin: 0;
}
html,
body {
height: 100%;
}
.wrapper {
function findNextSquare(sq) {
// Optimal solution
// return Math.sqrt(sq)%1? -1 : Math.pow(Math.sqrt(sq)+1,2);
// Return the next square if sq if a perfect square, -1 otherwise
var curVal = Math.sqrt(sq) + 1
var nextSq = Math.sqrt(sq) + 1
nextSq *= nextSq
//console.log(sq)
//console.log(currentNumber)
//Kata: https://www.codewars.com/kata/vasya-clerk/train/javascript
function tickets(peopleInLine){
var ticketPrice = 25
var bills = [0, 0, 0]
// Just count the bills... forget the register value
for (var i = 0; i < peopleInLine.length; i++) {
if (peopleInLine[i] == ticketPrice) {
bills[0] += 1 // Clients with $25 are the easy ones
// Simple function definition
function function01() {
console.log('This is function #1')
}
// Function expression
const fnExpression = () => {
console.log('This is an function epression example')
}
const http = require('http')
const port = 3000
const requestHandler = (request, response) => {
console.log(request.url)
response.end('Hello Node.js Server!')
}
const server = http.createServer(requestHandler)
// Kevin Pilard @kpilard Apr 11 16:17
// @jamesxv7
import { Validator } from 'vee-validate';
var app = new Vue({
el: '#app',
created () {
this.validator = new Validator(this.validationRules)
},
@jamesxv7
jamesxv7 / gist:26184b41e07c57816f2185ced14e11f8
Created May 7, 2017 16:45
Nice use of variables in a for loop.js
function someFunc(array) {
// some code...
// some code...
const length = array.length;
for (let index = 0; index < length; index++) {
const item = array[index];
// some
}
return 'some result';
}