Skip to content

Instantly share code, notes, and snippets.

View ZilvinasKucinskas's full-sized avatar
:octocat:
Trust Me, I’am Software Engineer

Zilvinas Kucinskas ZilvinasKucinskas

:octocat:
Trust Me, I’am Software Engineer
View GitHub Profile
@ZilvinasKucinskas
ZilvinasKucinskas / gist:7015751
Last active December 25, 2015 17:49
Merge sort function in Scala; Average complexity: O(n * log(n)); Worst complexity: O(n * log(n));
def msort[T](xs: List[T])(implicit ord: Ordering[T]): List[T] = {
val n = xs.length / 2
if (n == 0) xs
else {
def merge(xs: List[T], ys: List[T]) : List[T] = {
(xs, ys) match {
case (Nil, ys) => ys
case (xs, Nil) => xs
case (x :: xs1, y :: ys1) => {
if (ord.lt(x, y)) x :: merge(xs1, ys)
apply plugin: 'java'
apply plugin: 'scala'
// For those using Eclipse or IntelliJ IDEA
apply plugin: 'eclipse'
apply plugin: 'idea'
def findPlay20(){
def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
for(playExec in ['play.bat', 'play.sh', 'play']){
@ZilvinasKucinskas
ZilvinasKucinskas / frontendDevlopmentBookmarks.md
Created February 3, 2016 11:46 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@ZilvinasKucinskas
ZilvinasKucinskas / git-feature-workflow.md
Created March 22, 2016 14:09 — forked from blackfalcon/git-feature-workflow.md
Git basics - a general workflow

There are many Git workflows out there, I heavily suggest also reading the atlassian.com [Git Workflow][article] article as there is more detail then presented here.

The two prevailing workflows are [Gitflow][gitflow] and [feature branches][feature]. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited.

When using Bash in the command line, it leaves a bit to be desired when it comes to awareness of state. I would suggest following these instructions on [setting up GIT Bash autocompletion][git-auto].

Basic branching

When working with a centralized workflow the concepts are simple, master represented the official history and is always deployable. With each now scope of work, aka feature, the developer is to create a new branch. For clarity, make sure to use descriptive names like transaction-fail-message or github-oauth for your branches.

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@ZilvinasKucinskas
ZilvinasKucinskas / introrx.md
Created October 11, 2016 08:18 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@ZilvinasKucinskas
ZilvinasKucinskas / javascript_interview_questions.txt
Last active January 25, 2017 13:56
Awesome Javascript interview questions
1. Event delegation
We have html code:
<ul id="todo-app">
<li class="item">Walk the dog</li>
<li class="item">Pay bills</li>
<li class="item">Make dinner</li>
<li class="item">Code for one hour</li>
</ul>
@ZilvinasKucinskas
ZilvinasKucinskas / Gemfile
Created April 25, 2018 13:01 — forked from goncalvesjoao/Gemfile
Changes you need to make in order to make Devise use JWT Header Authentication
# Add the "https://github.com/jwt/ruby-jwt" gem to your "Gemfile"
gem 'jwt'
@ZilvinasKucinskas
ZilvinasKucinskas / facebook.rb
Created May 9, 2018 11:47 — forked from a14m/facebook.rb
Gist for manually OAuth2 facebook for Rails APIs
# lib/omniauth/facebook.rb
require 'httparty'
module Omniauth
class Facebook
include HTTParty
# The base uri for facebook graph API
base_uri 'https://graph.facebook.com/v2.3'
@ZilvinasKucinskas
ZilvinasKucinskas / bitcoin-pay.rb
Created June 5, 2018 19:01 — forked from Sjors/bitcoin-pay.rb
This script demonstrates how a bitcoin transaction is created and signed. Just pass in your own address and private key and it will prepare a transaction for you. You can then copy & paste that transaction into a webservice like Blockchain to send it. I wrote this mostly to understand better how it works. I sometimes had to "cheat" and look at t…
#!/usr/bin/env ruby
require 'open-uri'
require 'JSON'
require 'digest/sha2'
require 'pry'
require 'bigdecimal'
require 'bitcoin' # Because I need to cheat every now and then
# Usage:
# gem install pry json ffi ruby-bitcoin