Skip to content

Instantly share code, notes, and snippets.

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

Tomo Krajina tkrajina

🏠
Working from home
View GitHub Profile
@tkrajina
tkrajina / unmarshal_interface.go
Last active January 30, 2024 05:46
Unmarshal JSON to specific interface implementation
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type Something interface{}
@tkrajina
tkrajina / django_raw_sql_without_model.py
Last active November 27, 2023 18:55
Django raw sql without model
from django.db import connection
# If using cursor without "with" -- it must be closed explicitly:
with connection.cursor() as cursor:
cursor.execute('select column1, column2, column3 from table where aaa=%s', [5])
for row in cursor.fetchall():
print row[0], row[1], row[3]
@tkrajina
tkrajina / DebugUtils.java
Last active October 1, 2023 00:30
Copy android app database to sdcard
package info.puzz.a10000sentences.utils;
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
@tkrajina
tkrajina / remove_accents.go
Created January 31, 2016 08:21
Golang remove accents
package main
import (
"fmt"
"unicode"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
@tkrajina
tkrajina / call_method_with_reflection.go
Created April 1, 2016 09:14
Golang, call method (and fill arguments) with reflection
package main
import (
"fmt"
"reflect"
)
type Aaa struct {
a string
}
@tkrajina
tkrajina / group_waiter.go
Created April 1, 2016 05:19
Golang GroupWaiter (a wrapper aroung WaitGroup)
package main
import (
"errors"
"fmt"
"sync"
"time"
)
type GroupWaiter struct {
import sys
from django.conf import settings
from django.conf.urls import patterns
from django.http import HttpResponse
from django.core.management import execute_from_command_line
settings.configure(
DEBUG=True,
SECRET_KEY='trla_baba_lan',
@tkrajina
tkrajina / Dockerfile
Last active July 31, 2019 17:25
Dockerfile with Croatian LaTeX
# Build:
# docker build -t latex .
# Run latex:
# docker run -v $(pwd):/latex -it latex pdflatex git.tex
# docker run -v $(pwd):/latex -it /bin/bash
FROM ubuntu:latest
RUN apt-get -y update
RUN apt-get -y install texlive-latex-base texlive-lang-european
WORKDIR /latex
CMD ["/bin/bash"]
@tkrajina
tkrajina / Dockerfile
Created July 31, 2019 17:24
sgfutils Dockerfile
# Build:
# docker build -t sgfutils .
# Run sgfutils:
# docker run -v $(pwd):/sgfutils -it sgfutils
FROM ubuntu:latest
RUN apt-get -y update
RUN apt-get -y install curl
RUN apt-get -y install build-essential
RUN apt-get -y install libssl-dev
RUN curl https://homepages.cwi.nl/~aeb/go/sgfutils/sgfutils.tgz -o sgfutils.tgz
@tkrajina
tkrajina / unmarshal_json_to_custom_structs.go
Last active February 2, 2017 20:11
Unmarshal JSON to different structs (based on another field)
package main
import (
"encoding/json"
"fmt"
"sync"
)
type Something struct {
Aaa string `json:"aaa"`