Skip to content

Instantly share code, notes, and snippets.

View alfakini's full-sized avatar

Alan R. Fachini alfakini

View GitHub Profile
@alfakini
alfakini / Embedding GoLang into a Ruby application.md
Last active January 29, 2018 20:41 — forked from schweigert/Embedding GoLang into a Ruby application.md
Embedding GoLang into a Ruby application - Blogpost to Magrathealabs

#!inbox

Go Title

I am passionate about Ruby, but its execution time compared to other languages is extremely high, especially when we want to use more complex algorithms. In general, data structures in interpreted languages become incredibly slow compared to compiled languages. Some algorithms such as ´n-body´ and ´fannkuch-redux´ can be up to 30 times slower in Ruby than Go. This is one of the reasons I was interested in embedding Go code in a Ruby environment.

For those who do not know how shared libraries operate, they work in a similar way as DLLs in Windows. However, they have a native code with a direct interface to the C compiler.

Note

@alfakini
alfakini / cidades.md
Created May 17, 2018 02:38
cidades.md

× Done - In progress

# Cidade Crawler Parser
1 São Paulo
2 Rio de Janeiro -
3 Brasília
4 Salvador
@alfakini
alfakini / events.py
Last active August 15, 2021 05:40
Filesystem events monitoring with Python [events.py]
import os
from PIL import Image
from PIL.ImageOps import grayscale
from watchdog.events import RegexMatchingEventHandler
class ImagesEventHandler(RegexMatchingEventHandler):
THUMBNAIL_SIZE = (128, 128)
IMAGES_REGEX = [r".*[^_thumbnail]\.jpg$"]
def __init__(self):
@alfakini
alfakini / watcher.py
Created October 16, 2018 00:18
Filesystem events monitoring with Python [watcher.py]
import sys
import time
from watchdog.observers import Observer
from .events import ImagesEventHandler
class ImagesWatcher:
def __init__(self, src_path):
self.__src_path = src_path
self.__event_handler = ImagesEventHandler()
@alfakini
alfakini / events_two.py
Created October 16, 2018 00:34
Filesystem events monitoring with Python [events.py 2]
def on_created(self, event):
file_size = -1
while file_size != os.path.getsize(event.src_path):
file_size = os.path.getsize(event.src_path)
time.sleep(1)
self.process(event)

Keybase proof

I hereby claim:

  • I am alfakini on github.
  • I am alfakini (https://keybase.io/alfakini) on keybase.
  • I have a public key ASDKbWiwaCUJnq3RWVwqz3-aDkpboHOldbjGsrIvB6RqUwo

To claim this, I am signing this object: