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 / programatic_tests.go
Created June 24, 2015 00:33
Run golang tests programatically
package main
import (
"flag"
"fmt"
"testing"
)
func Test1(t *testing.T) {
if 1+2 != 3 {
@vaskoz
vaskoz / Anagrams.java
Created June 4, 2013 23:11
Print all the anagrams present in a list of words. Usage: java Anagarams < /usr/share/dict/words
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
public class Anagrams {
public static void main(String[] args) {
Map<String, Set<String>> anagrams = new HashMap<String, Set<String>>();
@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 |
@vaskoz
vaskoz / timeout_with_intervals.go
Created February 4, 2015 21:35
Use a timeout library to embedded a global timeout within smaller interval timeouts
package main
import (
"fmt"
"github.com/getlantern/withtimeout"
"net/http"
"time"
)
func main() {
@vaskoz
vaskoz / cpu_loader.go
Created January 22, 2015 19:35
Golang CPU bomb - actually prevents the main thread from getting scheduled to run
package main
import (
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
)
docker run -it --rm lambci/lambda:build-python3.8 /bin/bash 10:59:44
bash-4.2# pip list
Package Version
------------------- ----------
arrow 0.15.5
attrs 19.3.0
aws-lambda-builders 0.6.0
aws-sam-cli 0.40.0
aws-sam-translator 1.19.1
awscli 1.16.314
./gitea web 16:02:33 ☁ master ☀
2019/09/27 16:02:35 ...dules/setting/git.go:87:newGit() [I] Git Version: 2.23.0, Wire Protocol Version 2 Enabled
2019/09/27 16:02:35 routers/init.go:72:GlobalInit() [T] AppPath: /Users/vzdravevski/code/gitea/gitea
2019/09/27 16:02:35 routers/init.go:73:GlobalInit() [T] AppWorkPath: /Users/vzdravevski/code/gitea
2019/09/27 16:02:35 routers/init.go:74:GlobalInit() [T] Custom path: /Users/vzdravevski/code/gitea/custom
2019/09/27 16:02:35 routers/init.go:75:GlobalInit() [T] Log path: /Users/vzdravevski/code/gitea/log
2019/09/27 16:02:35 ...dules/setting/log.go:226:newLogService() [I] Gitea v1.9.0-dev built with go1.13
2019/09/27 16:02:35 ...dules/setting/log.go:269:newLogService() [I] Gitea Log Mode: Console(Console:info)
2019/09/27 16:02:35 ...les/setting/cache.go:45:newCacheService() [I] Cache Service Enabled
2019/09/27 16:02:35 ...s/setting/session.go:44:newSessionService() [I] Session Servic
public class Switch {
public static void main(String... args) {
var s = args[0];
int result = switch (s) {
case "Foo" -> 1;
case "Bar" -> 2;
default -> 0;
};
String msg2 = """
The quick brown fox\040\040
@vaskoz
vaskoz / OpenCvExample.groovy
Created June 8, 2013 22:41
This Groovy code results in Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
import org.opencv.core.Core
import org.opencv.core.CvType
import org.opencv.core.Mat
class Main {
static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
public static void main(String[] args) {
Mat m = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("m = " + m.dump());