Skip to content

Instantly share code, notes, and snippets.

View zauzaj's full-sized avatar

Bojan Jordanovski zauzaj

  • Belgrade
View GitHub Profile
@schweigert
schweigert / Embedding GoLang into a Ruby application.md
Last active April 11, 2025 19:24
Embedding GoLang into a Ruby application - Blogpost to Magrathealabs

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 Windows uses the DLL system, and in this case, this does not necessarily have to be in native code.

One example is DLLs written in C#, which runs on a virtual machine. Because I do not use windows, I ended up not testing if it is poss

@ghilead
ghilead / create_es_combined_index.rake
Last active January 18, 2019 12:08
Rake task for collocating multiple models as types in a single index.
# A Rake tasks to facilitate importing data from your models into a common Elasticsearch index.
#
# All models should declare a common index_name, and a document_type:
#
# class Article
# include Elasticsearch::Model
#
# index_name 'app_scoped_index'
# document_type 'articles'
#
@nebjak
nebjak / serbia_zip_codes.json
Last active December 23, 2024 15:53
List of Serbia zip codes with cities in form of JSON array
[
{ "city" : "Beograd", "_id" : 11000 },
{ "city" : "Beograd Vozdovac", "_id" : 11010 },
{ "city" : "Beograd Čukarica", "_id" : 11030 },
{ "city" : "Beograd Zvezdara", "_id" : 11050 },
{ "city" : "Beograd Palilula", "_id" : 11060 },
{ "city" : "Novi Beograd", "_id" : 11070 },
{ "city" : "Beograd Zemun", "_id" : 11080 },
{ "city" : "Beograd Rakovica", "_id" : 11090 },
{ "city" : "Kaluđerica", "_id" : 11130 },
@cander
cander / gist:5267753
Last active February 12, 2016 11:27
How to write to the Google Plus moments.insert API endpoint from Ruby.
# This Sinatra endpoint is something I added to the Google Ruby quick-start
# web app - https://developers.google.com/+/quickstart/ruby
# It demonstrates how to write to the moments.insert API, for which I
# couldn't find any Ruby examples.
post '/write_activity' do
# Check for stored credentials in the current user's session.
if !session[:token]
halt 401, 'User not connected.'
end
@lucasdavila
lucasdavila / password_strength.rb
Created January 16, 2013 03:16
Password strength with regex in Ruby
# example of using lookahead assertion to test password strength
# test if a given string contains at least a lowercase letter, a uppercase, a digit, a special char and 8+ chars
strong = "123ABCabc-"
strong[/^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\W]).{8,}$/]
# test if a given string contains at least a lowercase letter, a uppercase, a digit and 8+ chars
medium = "123ABCabc"
medium[/^(?=.*[a-zA-Z])(?=.*[0-9]).{8,}$/]