Skip to content

Instantly share code, notes, and snippets.

@kamoljan
kamoljan / networking.kt
Last active August 23, 2022 12:46
An example for DNS over HTTPS with OkHttp for Android in Kotlin
object Networking {
private val appCache = Cache(File("cacheDir", "okhttpcache"), 10 * 1024 * 1024)
private val bootstrapClient = OkHttpClient.Builder().cache(appCache).build()
private val dns = DnsOverHttps.Builder().client(bootstrapClient)
.url("https://dns.google/dns-query".toHttpUrl())
.bootstrapDnsHosts(InetAddress.getByName("8.8.4.4"), InetAddress.getByName("8.8.8.8"))
.build()
fun provideOkHttpClient(dataStorage: DataStorage): OkHttpClient {
@kamoljan
kamoljan / Dockerfile
Created August 7, 2022 09:50
How to run mosql in Dockerfile
FROM ruby:2.7
RUN mkdir -p /usr/src/app
COPY job.sh /usr/src/app
COPY collection /usr/src/app/collection
WORKDIR /usr/src/app
RUN gem install mosql
CMD ["bash", "mosql.sh"]
@kamoljan
kamoljan / mosql.sh
Created August 7, 2022 08:37
Run mosql concurrently in bash
#!/usr/bin/env bash
set -euo pipefail
MAP=('Collection1.yml' 'Collection2.yml' 'Collection3.yml')
for m in "${MAP[@]}"
do
mosql -c "./collection/${m}" --sql "${MOSQL_POSTGRESQL}" --mongo ${MOSQL_MONGODB} --only-db "${MOSQL_DB}" &
done
#!/bin/bash
#read user inputs
echo Git Username:
read GITNAME
echo Git Password:
read GITPASS
echo DCOS URL:
read DCOSURL
# build_args() {
# printf " --build-arg %s=%s" "$@"
# }
# sudo docker build $(build_args IMS_AD_PORT IMS_AD_PARSE_APP_ID IMS_AD_PARSE_JS_KEY IMS_AD_AWS_SQS_QUEUE) \
# -t kamoljan/ad:1.0 api
@kamoljan
kamoljan / gist:6407d388e669a8127cb4
Created February 17, 2016 15:55
how to install aws cli in harrow.io
hfold install-awscli
if ! which aws >/dev/null; then
sudo apt-get -y install awscli
fi
hfold --end
package main
import (
"image"
_ "image/jpeg"
_ "image/png"
"log"
"os"
"github.com/chai2010/webp"
def solution(A):
l = len(A)
if not (0 < l <= 100000):
return -1
s_l = s_r = 0
s = sum(A)
for i in range(l):
@kamoljan
kamoljan / new_gist_file
Created January 29, 2014 03:47
How to use Go Channel
package main
import (
"fmt"
)
func print(i int) string {
if i%3 == 0 {
if i%5 == 0 {
return fmt.Sprintf("%d PipipiPopopo\n", i)
@kamoljan
kamoljan / 0_reuse_code.js
Created January 29, 2014 03:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console