Skip to content

Instantly share code, notes, and snippets.

@clonekim
clonekim / db.clj
Created January 11, 2018 01:28
Honey SQL + CRUD Macro
(ns hub.db
(:require [clojure.tools.logging :as log]
[clojure.java.jdbc :as jdbc]
[mount.core :refer [defstate]]
[cheshire.core :refer [parse-string generate-string]]
[config.core :refer [env]]
[hub.util :as util]
[honeysql.core :as sql]
[honeysql.helpers :refer [merge-where]])
(:import [java.sql PreparedStatement]
<form method="POST" @submit="validateBeforeSubmit">
<span>Name</span>
<input type="text" class="formText" v-model.trim="user.username">
<p class="bind-error" v-show="validation.hasError('user.username')">{{validation.firstError('user.nickname')}}</p>
</form>
@clonekim
clonekim / io.clj
Created December 20, 2018 04:33
clojure pipestream
(let [in (java.io.PipedInputStream.)
out (java.io.PipedOutputStream.)
buf (java.io.BufferedWriter. (java.io.OutputStreamWriter. out))]
(.connect out in)
(doto buf
(.write "abdf")
(.write "abadfdf")
(.flush))
@clonekim
clonekim / GitHubService.java
Created November 1, 2019 00:43
Spring + RestTemplate
@Service
@GraphQLApi
public class GitHubService {
@Autowired
RestTemplate restTemplate;
@Bean
RestTemplate restTemplate() {
(ns apples.core
(:require [play-clj.core :refer :all]
[play-clj.g2d :refer :all]
[play-clj.math :refer :all]))
(declare apples main-screen)
(def speed 14)
(defn- get-direction []
(cond
@clonekim
clonekim / multipart_upload.go
Created June 8, 2020 23:53 — forked from mattetti/multipart_upload.go
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@clonekim
clonekim / Application.kt
Last active March 31, 2023 03:52
Ktor+koin
import com.fasterxml.jackson.databind.SerializationFeature
import com.google.api.services.docs.v1.Docs
import com.google.api.services.drive.Drive
import io.ktor.application.Application
import io.ktor.application.call
import io.ktor.application.install
import io.ktor.features.*
import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode
import io.ktor.http.content.resources
@clonekim
clonekim / oauth.clj
Created July 23, 2020 03:28
OAuth2 by Clojure
(ns backend.google.oauth
(:require [cheshire.core :refer [parse-string generate-string]]
[mount.core :refer [defstate]]
[buddy.core.keys :as keys]
[buddy.core.dsa :as dsa]
[backend.config :refer [env]]
[org.httpkit.client :as http])
(:import org.apache.commons.codec.binary.Base64))
(def access_token (atom nil))
(defstate private-key :start (-> env
@clonekim
clonekim / OkHttpTest.kt
Last active August 11, 2020 04:05
OkHttp/soap consumer
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import java.io.IOException
import java.io.InputStream
import java.security.KeyStore
import java.security.KeyStoreException
import java.security.NoSuchAlgorithmException
import java.security.cert.CertificateException
@clonekim
clonekim / config.edn
Created August 12, 2020 01:14
Boot httpkit using integrant
{:http {:port 9090 :handler #ig/ref :handler/app}
:handler/app {}}