This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BackgroundJob | |
def initialize(cmd) | |
@pid = fork do | |
# this code is run in the child process | |
# you can do anything here, like changing current directory or reopening STDOUT | |
exec cmd | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Led | |
#numero da 1 a 3 | |
def initialize(ledno) | |
ledno++ # passo 0 ma comando 1 | |
ledno=1 if ledno<1 | |
ledno=3 if ledno>3 | |
@ledsyspath="/sys/devices/platform/leds_alix2/leds/alix:#{ledno}/" | |
end | |
def blink(millisec) | |
File.open(@ledsyspath+'trigger','w') { |f| f.write('timer') } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SECONDS_BETWEEN_REQUEST=5 | |
enable :sessions | |
def ratelimit? | |
now=Time.new.to_i | |
session['lastrequest']||=0 #inizializza se non presente | |
result=(now-session['lastrequest'])<SECONDS_BETWEEN_REQUEST #passati dall'ultima richiesta ? | |
session['lastrequest']=now # aggiorna | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"></meta> | |
<meta | |
name="viewport" | |
content="width=device-width, initial-scale=1, shrink-to-fit=no" | |
></meta> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; setup | |
; | |
; sudo apt-get install cmatrix nasm ; nasm -f elf64 -o matrix.o matrix.asm ; ld -o matrix matrix.o; ./matrix | |
SECTION .text | |
global _start | |
_start: | |
mov rdx, environment ; address of environment variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sense_hat import SenseHat | |
import time | |
import math | |
sensehat = SenseHat() | |
sensehat.low_light = True | |
class Spinner(): | |
def __init__(self,sensehat): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ephem | |
from math import radians, degrees, cos, sin, asin, sqrt | |
from sense_hat import SenseHat | |
import time | |
import math | |
import os | |
import datetime | |
from time import sleep,strftime | |
import logging | |
import logzero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module main | |
struct List { | |
head &Node | |
name string | |
} | |
struct Node { | |
mut: data int | |
next &Node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"log" | |
"golang.org/x/crypto/ssh" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/strutils | |
import std/sequtils | |
proc count_increases(items : seq[int]) : int = | |
for i in 1 .. items.high: | |
if items[i] > items[i - 1]: | |
inc result | |
proc get_sums(items: seq[int]) : seq[int] = | |
for i in countup(2,items.len-1): |
OlderNewer