Skip to content

Instantly share code, notes, and snippets.

View remogatto's full-sized avatar

Andrea Fazzi remogatto

View GitHub Profile
@remogatto
remogatto / main.go
Last active January 12, 2024 21:19
Basic BubbleTea lipgloss-styled application
package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
class Modulo
include Comparable
[:+, :-, :*, :**].each do |meth|
define_method(meth) { |other_n| Modulo.new(@n.send(meth, other_n.to_i), @m) }
end
def initialize(n = 0, m = 26)
@n, @m = n % m, m
end
def <=>(other_n)
@n <=> other_n.to_i
@remogatto
remogatto / .gitignore
Created October 11, 2011 18:47 — forked from rpl/.gitignore
Go Websocket implementation, hybi and Firefox
_obj
*~
bin
func HomeHandler(w http.ResponseWriter, req *http.Request) *Error {
if login, accessToken := getUserInfoFromCookie(req); login != "" && accessToken != "" {
api := NewGithubAPI(login, accessToken)
if gists, err := api.ListGists(); err != nil {
return &Error{err, "Internal server error", 500}
} else {
w.(*Template).Data = map[string]interface{}{"login": login, "gists": gists}
return nil
}
}
@remogatto
remogatto / gist:1018401
Created June 10, 2011 07:45
WorldOfSpectrum Resource Fetcher
package main
import (
"path"
"regexp"
"http"
"log"
"io/ioutil"
"flag"
"fmt"
@remogatto
remogatto / gist:839055
Created February 22, 2011 17:51 — forked from sub/gist:839014
def create
offer = Offer.find(params[:offer_id])
if params[:offer_id]
task = JSON.parse(params[:tasks])
unless task.nil?
# seleziona i parametri rispondenti alla RE active_(.*)
# in questo modo otterrai una lista "elems" di al max 3 elementi del tipo
# elems == ['active_gift', 'active_encoding', ...]
elems.each do |elem|
klass_name = elem.split('_')[1].capitalize
def create
['gift', 'encoding', 'epd'].each do |param|
eval <<EOC
if active_#{param}
puts "#{param} CREATE"
delete_item = #{param.capitalize}.find_by_task_id(task_id)
delete_item.delete unless delete_item.nil?
new_item = #{param.capitalize}.new(#{param})
new_task.#{param} = new_item
new_task.save
package spectrum
import "time"
const (
second = 1e9
ms = 1e6
)
type FpsCounter struct {
package spectrum
import (
"testing"
"time"
)
const (
second = 1e9
ms = 1e6