Skip to content

Instantly share code, notes, and snippets.

View vaskoz's full-sized avatar
🏠
Working from home

Vasko Zdravevski vaskoz

🏠
Working from home
View GitHub Profile
@vaskoz
vaskoz / builder.go
Last active January 22, 2024 10:54
Golang Builder pattern
package main
import "strconv"
import "fmt"
type Color string
type Make string
type Model string
const (
@vaskoz
vaskoz / method_types.go
Created March 21, 2014 19:56
Go Method Types
package main
import "fmt"
type Point struct {}
func (p *Point) Scale() {
fmt.Println("method")
}
@vaskoz
vaskoz / AscendingSortSpeed.java
Last active August 29, 2015 13:57
Java vs Go built-in sort speed. Testing 1 BILLION integers.
import java.util.*;
public class AscendingSortSpeed {
public static void main(String[] args) {
int[] data = new int[1_000_000_000]; // 1 BILLION INTS
for (int i = 0; i < data.length; i++) {
data[i] = i;
}
// Sort to ascending
long start = System.currentTimeMillis();
@vaskoz
vaskoz / optimal_currency.rb
Created March 8, 2014 18:55
The optimal denominations for a currency to reduce the
#denom = popular_usd_denom = [100_00, 50_00, 20_00, 10_00, 5_00, 1_00, 25, 10, 5, 1]
#denom = official_usd_denom = [100_00, 50_00, 20_00, 10_00, 5_00, 2_00, 1_00, 50, 25, 10, 5, 1]
#denom = power2_denom = [64_00, 32_00, 16_00, 8_00, 4_00, 2_00, 1_00, 32, 16, 8, 4, 2, 1]
denom = power3_denom = [27_00, 9_00, 3_00, 1_00, 27, 9, 3, 1]
#denom = power4_denom = [64_00, 16_00, 4_00, 1_00, 64, 16, 4, 1]
total_prices = 100_00
needed = Array.new(total_prices, 0)
denom_count = denom.size
@vaskoz
vaskoz / gokogiri_ex2.go
Created March 6, 2014 15:41
Go Research Skeleton for testing out Gokogiri
package main
import (
g "github.com/moovweb/gokogiri"
"github.com/moovweb/gokogiri/html"
. "io/ioutil"
"fmt"
"os"
"strconv"
)
@vaskoz
vaskoz / gokogiri1.go
Created March 4, 2014 00:09
Simple Gokogiri example file that reads and writes the file.
package main
import (
g "github.com/moovweb/gokogiri"
. "io/ioutil"
_ "fmt"
"os"
)
func main() {
@vaskoz
vaskoz / boot.rb
Created March 1, 2014 22:03
Rails 4.0.3 with TracePoint on Ruby 2.1.1 (MRI)
##### Rails app: config/boot.rb Added by VaskoZ
@stats = {}
@tp = TracePoint.trace(:a_call) do |tp|
@stats[tp.defined_class] ||= {}
@stats[tp.defined_class][tp.method_id] ||= 0
@stats[tp.defined_class][tp.method_id] += 1
end
@tp.enable
##### End VaskoZ changes
# Set up gems listed in the Gemfile.
@vaskoz
vaskoz / EarlyLateBindings.java
Created February 28, 2014 19:46
Early vs Late Binding in Java
class A {
void print() {
System.out.println(secret());
}
String secret() {
return "A";
}
static void staticPrint() {
System.out.println(staticSecret());
@vaskoz
vaskoz / embed_struct.go
Created February 28, 2014 16:42
Embedded Structs interview question
package main
import "fmt"
type A struct{}
type B struct {
A
}
func (a A) HiThere() {
@vaskoz
vaskoz / answer.txt
Created January 1, 2014 23:12
Sudoku puzzle & solution generated on 16x16 grid using my Sudoku BackTracker
Puzzle Solved, here is the solution:
8 15 11 1 | 6 2 10 14 | 12 7 13 3 | 16 9 4 5 |
10 6 3 16 | 12 5 8 4 | 14 15 1 9 | 2 11 7 13 |
14 5 9 7 | 11 3 15 13 | 8 2 16 4 | 12 10 1 6 |
4 13 2 12 | 1 9 7 16 | 6 10 5 11 | 3 15 8 14 |
-----------------------------------------------
9 2 6 15 | 14 1 11 7 | 3 5 10 16 | 4 8 13 12 |
3 16 12 8 | 2 4 6 9 | 11 14 7 13 | 10 1 5 15 |
11 10 5 13 | 8 12 3 15 | 1 9 4 2 | 7 6 14 16 |
1 4 7 14 | 13 10 16 5 | 15 6 8 12 | 9 2 3 11 |