Skip to content

Instantly share code, notes, and snippets.

mele = ['annurca', 'fuji','cox', 'golden','renetta', 'granny smith', 'elstar', 'pink lady']
partitions = function (set, n){
var albero={}
if(n>0){
for(var i=0; i< set.length; i++){
var tset=set.slice()
var key=tset.splice(i,1)[0];
@andijcr
andijcr / gist:9503466
Created March 12, 2014 09:14
Adafruit MotorShield test dc motor
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *sx = AFMS.getMotor(3), *dx =AFMS.getMotor(1);
void setup(){
AFMS.begin();
@andijcr
andijcr / gist:f4a660fde4035fb0a3aa
Created August 4, 2014 13:30
relevant section of avrdude.conf with correct timings to work with adafruit's trinket
#------------------------------------------------------------
# ATtiny85
#------------------------------------------------------------
part
id = "t85";
desc = "ATtiny85";
has_debugwire = yes;
flash_instr = 0xB4, 0x02, 0x12;
eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
@andijcr
andijcr / test_hc-sr04.ino
Created October 1, 2014 17:32
test hc-sr04
//11 trig
//10 echo
//13 led
void setup(){
pinMode(11, OUTPUT);
pinMode(10, INPUT);
pinMode(13, OUTPUT);
}
(defn daje [x](/(* (+ x 1) x) 2))
# Ctrl+Alt+B per compilare!
Lei ha clacsonato
voglio Io, Mascetti come fosse 72
Io a posterdati
voglio Cicinelli, Mascetti come fosse Io più 29
#!/bin/bash
#
# usage: run2pass.sh FileToEncode.Extension
# produces: FileToEncode.Extension.costant.webm in the same directory
# requires: docker
# vp9 2 pass encoding with recomended settings for costant quality encoding
# uses docker image from jrottenberg/ffmpeg
# taken from https://sites.google.com/a/webmproject.org/wiki/ffmpeg/vp9-encoding-guide
#
@andijcr
andijcr / gist:780ce9a67462299ec4ec
Created July 1, 2015 16:46
anagram palindrome test
int main(){
vector<int> char_count(int('z'-'a')+1);
string word;
cin >> word;
for_each(begin(word), end(word), [&char_count](char c){ char_count[int(c-'a')]++; });
auto odd=count_if(begin(char_count), end(char_count), [](int count){ return (count%2) == 1;});
if(word.length()%2 == 1) --odd;
cout << (odd==0)? "YES" : "NO";
}
@andijcr
andijcr / larson_scanner.ino
Last active September 2, 2015 11:35
larson scanner with neopixel led strip. the gist is for each loop to decay al the leds in the strip, and then add a moving full-on led. example here: https://www.youtube.com/watch?v=htmgPjYIphI
#Using an Adafruit NeoPixel led strip http://www.adafruit.com/product/1138
#include <Adafruit_NeoPixel.h>
#define MAX_P 60
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
@andijcr
andijcr / tree.js
Created September 16, 2015 20:04
convert a tree representation as (H2,((H4,H5)H3,H6)H7)H1 in a object structure
Tree = function(lbl, lT, rT){
this.label=lbl
this.leftTree= lT
this.rightTree= rT
};
function isAlphaNumeric(char) {
var code
code = char.charCodeAt(0);
if (!(code > 47 && code < 58) && // numeric (0-9)