Skip to content

Instantly share code, notes, and snippets.

View albertshala's full-sized avatar
🎯
Focusing

Albert Shala albertshala

🎯
Focusing
View GitHub Profile
/**
Reverse a string
**/
function reverseMe(int){
return int.toString().split('').reverse().join('');
}
reverseMe('albert') --> "trebla"
/**
Fibonacci sequence algorithm in JS
**/
function fib(x){
if (x === 0) return 0;
if (x === 1) return 1;
return fib(x - 1) + fib(x - 2)
}
/**
Compute the moving avarage, with window size; k = 3
**/
var values = [3,2,4,5,7,6,8,9];
var size = 3;
function avarage(items, size){
var tally = 0;
var total = [];
// Sample Data from Backend Service
/*
[
{
"name": "Salsas R Us",
"inventory": {
"Ghost Chili Salsa": {"price": 7, "quantity": 17},
"Mild Salsa": {"price": 4.5, "quantity": 0}
}
},
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tabs</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<style>
* { padding:0; margin:0; }
html, body {
font-family:sans-serif;
class ContactList extends React.Component {
render() {
const people = [
{"name": "albert"},
{"name": "leart"},
{"name": "liana"},
{"name": "vjollca"}
];
return <ol>
//Card Component
const Card = (props) => {
return (
<div style={{margin: '1em'}}>
<img width="75" src={props.avatar_url}/>
<div style={{display: 'inline-block', marginLeft: 10}}>
<div style={{fontSize: '1.25em', fontWeight: 'bold'}}>
{props.name}
</div>
<div>{props.company}</div>
@albertshala
albertshala / gist:1f565935f6ba2215e1b4
Last active August 29, 2015 14:16
Higher-Order Functions
function add(a, b) {
return a + b;
}
function mul(a, b) {
return a * b;
}
function applyf(func) {
return function(a) {
@albertshala
albertshala / gist:8406399
Created January 13, 2014 19:26
.gitignore for the Play Framework
.DS_Store
.svn/
log
logs
modules
precompiled
project/project
project/target
target
tmp
PS1='->'
export PS1="___________________\n| \w @ \h (\u) \n| => "
export PS2="| => "
# Reload Bash Profile
alias reload='source ~/.bash_profile'
# Create a Blank Site Template in Dropbox
function proj() { cp -R /Users/{user}/Dropbox/site_template '.'; mv site_template $1; }