Skip to content

Instantly share code, notes, and snippets.

@kamoljan
kamoljan / 0_reuse_code.js
Created Jan 29, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kamoljan
kamoljan / new_gist_file
Created Jan 29, 2014
How to use Go Channel
View new_gist_file
package main
import (
"fmt"
)
func print(i int) string {
if i%3 == 0 {
if i%5 == 0 {
return fmt.Sprintf("%d PipipiPopopo\n", i)
View gist:e4fc31c40661eb3bc3ea
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):
View gist:48a71140ac61ed5d98e9
package main
import (
"image"
_ "image/jpeg"
_ "image/png"
"log"
"os"
"github.com/chai2010/webp"
@kamoljan
kamoljan / gist:6407d388e669a8127cb4
Created Feb 17, 2016
how to install aws cli in harrow.io
View gist:6407d388e669a8127cb4
hfold install-awscli
if ! which aws >/dev/null; then
sudo apt-get -y install awscli
fi
hfold --end
View gist:e73f5cb563a4e1d2184c
# 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
View marathon-recovery.sh
#!/bin/bash
#read user inputs
echo Git Username:
read GITNAME
echo Git Password:
read GITPASS
echo DCOS URL:
read DCOSURL
@kamoljan
kamoljan / mosql.sh
Created Aug 7, 2022
Run mosql concurrently in bash
View mosql.sh
#!/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
@kamoljan
kamoljan / Dockerfile
Created Aug 7, 2022
How to run mosql in Dockerfile
View 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 / networking.kt
Last active Aug 23, 2022
An example for DNS over HTTPS with OkHttp for Android in Kotlin
View networking.kt
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 {