This time I have made a small Midi Piano...and excuse my total lack of Piano skills -:(
For this I used Python, AdaFruit_BBIO, PyGame and Timidity++.
Greetings,
Blag.
Development Culture.
My Rants related to SAP, Scripting Languages, Technologies and everything else I wanted to talk about...
| Hashtags.js |
|---|
var system = require('system');
var webpage = require('webpage').create();
webpage.viewportSize = { width: 1280, height: 800 };
webpage.scrollPosition = { top: 0, left: 0 };
var userid = system.args[1];
var profileUrl = "http://www.twitter.com/" + userid;
webpage.open(profileUrl, function(status) {
if (status === 'fail') {
console.error('webpage did not open successfully');
phantom.exit(1);
}
var i = 0,
top,
queryFn = function() {
return document.body.scrollHeight;
};
setInterval(function() {
top = webpage.evaluate(queryFn);
i++;
webpage.scrollPosition = { top: top + 1, left: 0 };
if (i >= 5) {
var twitter = webpage.evaluate(function () {
var twitter = [];
forEach = Array.prototype.forEach;
var tweets = document.querySelectorAll('[data-query-source="hashtag_click"]');
forEach.call(tweets, function(el) {
twitter.push(el.innerText);
});
return twitter;
});
twitter.forEach(function(t) {
console.log(t);
});
phantom.exit();
}
}, 3000);
});
|
| TwitterHashtags.go |
|---|
package main
import ( "os/exec"
"strings"
"fmt" )
func main() {
cmd := exec.Command("phantomjs","--ssl-protocol=any","Hashtags.js", "Blag")
out, err := cmd.Output()
if err != nil {
println(err.Error())
return
}
Tweets := strings.Split(string(out), "\n")
charmap := make(map[string]int)
for _, value := range Tweets {
if value != "" {
charmap[value] += 1
}
}
for key, value := range charmap {
if value >= 5 {
fmt.Print("(", key, ", ")
fmt.Println(value, ")")
}
}
}
|
| LED.go |
|---|
package main
import ( "fmt"
"strconv"
"strings" )
func main() {
fmt.Print("Enter a number: ")
var num int
var list []string
var line1, line2, line3 string
fmt.Scanf("%d", &num)
numList := strings.Split(strconv.Itoa(num), "")
romans := map[string]string {
"0" : " _ ,| | ,|_| ",
"1" : " ,| ,| ",
"2" : " _ , _| ,|_ ",
"3" : "_ ,_| ,_| ",
"4" : " ,|_| , | ",
"5" : " _ ,|_ , _| ",
"6" : " _ ,|_ ,|_| ",
"7" : "_ , | , | ",
"8" : " _ ,|_| ,|_| ",
"9" : " _ ,|_| , _| ",
}
for _, value := range numList {
list = strings.Split(romans[value],",")
line1 += list[0]
line2 += list[1]
line3 += list[2]
}
fmt.Println(line1)
fmt.Println(line2)
fmt.Println(line3)
}
|
| Fibonacci.go |
|---|
package main
import ( "fmt"
"strconv" )
func main() {
fmt.Print("Enter a number: ")
var num int
fmt.Scanf("%d", &num)
fmt.Print(fib(num, 0, 1))
}
func fib(num int, a int, b int) string{
var result string
if a > 0 && num > 1 {
result += strconv.Itoa(a+b) + " " + fib(num-1, a+b, a)
} else if a == 0 {
result = strconv.Itoa(a) + " " + strconv.Itoa(b) +
" " + strconv.Itoa(a+b) +
" " + fib(num-1, a+b, b)
}
return result
}
|