Skip to content

Instantly share code, notes, and snippets.

Avatar

Esdras Beleza esdrasbeleza

View GitHub Profile
View lightest2.go
func (c LightestOperation) Result(images []containers.ImageContainer) (image.Image, error) {
if len(images) == 0 {
return nil, nil
} else if len(images) == 1 {
return images[0].GetImage(), nil
}
firstImage := images[0].GetImage()
bounds := firstImage.Bounds()
lightest := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy()))
View image_containers.go
type ImageContainer interface {
GetImage() image.Image
}
type FileImageContainer struct {
Filename string
}
func (f FileImageContainer) GetImage() image.Image {
file, _ := os.Open(f.filename)
@esdrasbeleza
esdrasbeleza / lightest1.go
Last active Aug 29, 2015
First version of Lightest operation
View lightest1.go
func (c LightestOperation) Result(images []image.Image) (image.Image, error) {
firstImage := images[0]
bounds := firstImage.Bounds()
lightest := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy()))
draw.Draw(lightest, bounds, firstImage, bounds.Min, draw.Src)
for _, currentImage := range images {
if currentImage.Bounds() != bounds {
return nil, errors.New("The images have different size!")
}
@esdrasbeleza
esdrasbeleza / lightest_excerpt.go
Last active Aug 29, 2015
lightest() function
View lightest_excerpt.go
func (c LightestOperation) lightest(color1, color2 color.RGBA) color.Color {
if c.luminance(color1) > c.luminance(color2) {
return color1
} else {
return color2
}
}
func (c LightestOperation) luminance(someColor color.Color) uint32 {
r, g, b, _ := someColor.RGBA()
View Preferences.sublime-settings
{
"bold_folder_labels": true,
"fade_fold_buttons": false,
"font_face": "Fira Mono",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
@esdrasbeleza
esdrasbeleza / check_connection.sh
Last active Dec 12, 2015
A script to verify if my connection is up and running. Put it to run in your crontab and you can have logs of your broadband internet connection, for example. Call $ check_connection.sh > output.log
View check_connection.sh
#!/bin/sh
datetime=`date +%Y-%m-%d\ %H:%M:%S`
my_ip=`curl -s ifconfig.me`
exit_code=$?
if [ $exit_code == 0 ]; then
echo $datetime [ONLINE] $my_ip
else
echo $datetime [OFFLINE] Exit code: $exit_code
You can’t perform that action at this time.