Skip to content

Instantly share code, notes, and snippets.

View proudlygeek's full-sized avatar
🍕

Gianluca Bargelli proudlygeek

🍕
View GitHub Profile
@proudlygeek
proudlygeek / alessinator.py
Created May 18, 2015 14:30
Alessinator™
print 'lo so ' * 10000
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
@proudlygeek
proudlygeek / servo_ex.c
Created April 26, 2015 21:47
Arduino Servo basic example
#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;
void setup() {
myServo.attach(9);
<?php
// You can use an abstract class as well
trait Cachable {
private $cache = [];
public function cached($method, $args) {
echo "[Cache] Called $method\n";
if (!isset($this->cache[$method])) {
@proudlygeek
proudlygeek / example.php
Last active August 29, 2015 14:17
PHP Cache Trait
<?php
trait Cachable {
private $cache = [];
public function cached($method, $args) {
echo "[Cache] Called $method\n";
if (!isset($this->cache[$method])) {
echo "[Cache] Saving method in cache\n";
@proudlygeek
proudlygeek / color_lamp.c
Last active August 29, 2015 14:17
color lamp
const int greenLEDPin = 9;
const int redLEDPin = 10;
const int blueLEDPin = 11;
const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;
int redValue = 0;
int greenValue = 0;
@proudlygeek
proudlygeek / Gemfile
Last active August 29, 2015 14:17
Ruby Datamapper + Sinatra PUT
source 'https://rubygems.org'
gem 'sinatra'
gem 'thin'
gem 'data_mapper'
gem 'dm-sqlite-adapter'
@proudlygeek
proudlygeek / index.html
Last active August 29, 2015 14:15
test-injection
<!DOCTYPE html>
<html>
<head>
<title>Hello React</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script>
</head>
<body>
<div id="main"></div>
<script type="text/jsx" src="main.js"></script>
@proudlygeek
proudlygeek / lru.js
Created February 3, 2015 00:59
LRU Cache Implementation
/**
* LRU Cache
*
* http://www.codewars.com/kata/53b406e67040e51e17000c0a
*
*/
function LRUCache(capacity, init) {
var data = init || {};
var timestamps = {};
var capacity = capacity;
@proudlygeek
proudlygeek / curry.js
Last active June 28, 2016 01:48
Curry Callbacks
function callbackCurry(callbacks) {
var memoize = function memoize(xs) {
if (!xs.length) return null;
var tail = xs.slice(1),
head = xs[0];
return head.bind(undefined, memoize(tail));
};