Skip to content

Instantly share code, notes, and snippets.

View djodjoni's full-sized avatar

Kalin Maldzhanski djodjoni

View GitHub Profile
@djodjoni
djodjoni / cca2-to-cca3
Created June 23, 2014 16:16
json Map helper to/from cca2-cca3 country codes
{"AF":"AFG","AX":"ALA","AL":"ALB","DZ":"DZA","AS":"ASM","AD":"AND","AO":"AGO","AI":"AIA","AQ":"ATA","AG":"ATG","AR":"ARG","AM":"ARM","AW":"ABW","SH":"SHN","AU":"AUS","AT":"AUT","AZ":"AZE","BS":"BHS","BH":"BHR","BD":"BGD","BB":"BRB","BY":"BLR","BE":"BEL","BZ":"BLZ","BJ":"BEN","BM":"BMU","BT":"BTN","BO":"BOL","BQ":"BES","BA":"BIH","BW":"BWA","BV":"BVT","BR":"BRA","IO":"IOT","VG":"VGB","BN":"BRN","BG":"BGR","BF":"BFA","BI":"BDI","KH":"KHM","CM":"CMR","CA":"CAN","CV":"CPV","KY":"CYM","CF":"CAF","TD":"TCD","CL":"CHL","CN":"CHN","CX":"CXR","CC":"CCK","CO":"COL","KM":"COM","CG":"COG","CD":"COD","CK":"COK","CR":"CRI","HR":"HRV","CU":"CUB","CW":"CUW","CY":"CYP","CZ":"CZE","DK":"DNK","DJ":"DJI","DM":"DMA","DO":"DOM","EC":"ECU","EG":"EGY","SV":"SLV","GQ":"GNQ","ER":"ERI","EE":"EST","ET":"ETH","FK":"FLK","FO":"FRO","FJ":"FJI","FI":"FIN","FR":"FRA","GF":"GUF","PF":"PYF","TF":"ATF","GA":"GAB","GM":"GMB","GE":"GEO","DE":"DEU","GH":"GHA","GI":"GIB","GR":"GRC","GL":"GRL","GD":"GRD","GP":"GLP","GU":"GUM","GT":"GTM","GG":"GGY",
public class PipedStreamExample {
public static void main(String[] args) throws IOException, InterruptedException {
final PipedInputStream pipedInputStream=new PipedInputStream();
final PipedOutputStream pipedOutputStream=new PipedOutputStream();
/*Connect pipe*/
pipedInputStream.connect(pipedOutputStream);
/*Thread for writing data to pipe*/
@djodjoni
djodjoni / JacksonKotlinModuleExample.kt
Created August 22, 2018 08:30 — forked from hansenji/JacksonKotlinModuleExample.kt
Jackson Kotlin Module Example
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
fun main(args: Array<String>) {
// val mapper = ObjectMapper().registerModule(KotlinModule())
// val mapper = ObjectMapper().registerKotlinModule()
val mapper = jacksonObjectMapper()
val writer = mapper.writerWithDefaultPrettyPrinter()
val json1 = writer.writeValueAsString(Data1(1, "Foo", "Bar"))
@djodjoni
djodjoni / kafka-cheat-sheet.md
Created August 19, 2018 12:54 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@djodjoni
djodjoni / upload.js
Created August 12, 2018 16:40 — forked from ibreathebsb/upload.js
file upload from dataUrl with axios
// Note: only for modern browser
import axios from 'axios'
// helper function: generate a new file from base64 String
const dataURLtoFile = (dataurl, filename) => {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
@djodjoni
djodjoni / fileUpload.vue
Created August 12, 2018 15:04 — forked from raisiqueira/fileUpload.vue
Simple file upload with Vue and Axios
<style>
input[type="file"]{
position: absolute;
top: -500px;
}
div.file-listing{
width: 200px;
}
@djodjoni
djodjoni / context-vocab-array-combined-iri-coerce.json
Created August 3, 2018 08:54 — forked from niklasl/context-vocab-array-combined-iri-coerce.json
JSON-LD context array with different vocabs using combined iri-coerce objects
{
"@context": [
{
"@vocab": "http://www.w3.org",
"label": "/2000/01/rdf-schema#label",
"comment": "/2000/01/rdf-schema#comment",
"prefLabel": "/2004/02/skos/core#prefLabel",
"altLabel": "/2004/02/skos/core#altLabel",
"prev": {"/1999/xhtml/vocab#prev": "@iri"},
@djodjoni
djodjoni / README.md
Created June 24, 2018 10:45
Vue + Firebase + Auth Demo

Vue + Firebase + Auth Demo

A simple App using Vue.js & Firebase with Auth.

See the DEMO.

@djodjoni
djodjoni / Query.java
Created June 10, 2018 16:37 — forked from sockeqwe/Query.java
RxJava wrapper for Firebase ValueEventListeners
package com.usehomeroom.vasuki.data;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fernandocejas.arrow.optional.Optional;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
@djodjoni
djodjoni / foundation-chosen.sass
Created June 3, 2018 05:55 — forked from dsandstrom/foundation-chosen.sass
Foundation 5 and Chosen CSS Merger
// Foundation and Chosen CSS Merger
// ZURB Foundation v5 - Harvest Chosen v1.1
// Add to the bottom of foundation_and_overrides.scss: `@import 'foundation-chosen';`
$chosen-form-spacing: $form-spacing / 4 + rem-calc(1)
$chosen-input-height: ($input-font-size + ($form-spacing * 1.5) - rem-calc(1))
$chosen-input-height-multi: ($input-font-size + ($form-spacing * 1.5) - rem-calc(5))
$chosen-border-radius: 0
$chosen-highlighted: $primary-color