Skip to content

Instantly share code, notes, and snippets.

View json4s_example.scala
import org.json4s._
import org.json4s.native.JsonMethods._
import org.json4s.native.Serialization
import org.json4s.native.Serialization.write
case class A(s: String, i: Int)
implicit val formats = Serialization.formats(NoTypeHints)
val a = A("a", 1)
@ruseel
ruseel / keycloak-rest-api-sample.clj
Last active Feb 27, 2020
Keycloak Admin REST API Sample
View keycloak-rest-api-sample.clj
;; this worked for me
;;
(defn access-token []
(->
(client/post
(str base-url "/auth/realms/" realm "/protocol/openid-connect/token")
{:accept :json
:form-params {"client_id" "admin-cli"
"username" some-username
View compare.py
import random
import statsmodels
import pmap
groups = ["control", "treatment"]
POPULATION = 1e6
SAMPLE = 1e4
TRIES_PER_PERSON = 3
@ruseel
ruseel / gist:bcd7ec7c31ef101d68112ea2a1b2709f
Created Oct 1, 2018
java.sql.Timestamp - clojure.data.json
View gist:bcd7ec7c31ef101d68112ea2a1b2709f
(require '[clojure.data.json :refer [write JSONWriter]])
(defn write-timestamp [x out]
(write (str x) out))
(extend java.sql.Timestamp JSONWriter {:-write write-timestamp})
View deps.edn
{:deps
{clj-time {:mvn/version "0.14.2"}
mysql/mysql-connector-java {:mvn/version "8.0.12"}
org.clojure/java.jdbc {:mvn/version "0.7.8"}
org.clojure/data.json {:mvn/version "0.2.6"}}}
View gist:26e98aea480f8c2138fa070c5f3930fc
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< org.apache.hadoop:hadoop-aws >--------------------
[INFO] Building Apache Hadoop Amazon Web Services support 2.7.7-socar1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (create-testdirs) @ hadoop-aws ---
[INFO] Executing tasks
main:
@ruseel
ruseel / sample.scala
Created Aug 1, 2018
scala - google storage transfer job create
View sample.scala
#
# service-account can call Google StorageTransfer API.
#
import scala.collection.JavaConversions._
val c = createStorageTransferClient
val j = new TransferJob()
.setProjectId("projec-id-a")
@ruseel
ruseel / README.md
Last active Aug 1, 2018
Google AdSense API with ServiceAccount - Not possible
View README.md
@ruseel
ruseel / googe_spreadsheet_v4_append.java
Last active Mar 16, 2018
spreadsheet.values.append java example
View googe_spreadsheet_v4_append.java
// credential from ServiceAccount json file
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream(p))
.createScoped(Collections.singleton(SheetsScopes.SPREADSHEETS));
Sheets service = new Sheets.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME)
.build();
AppendValuesResponse r = service.spreadsheets().values().append(
spreadsheetId,
@ruseel
ruseel / get_oauth2_token.py
Last active Oct 11, 2017 — forked from clarketm/get_oauth2_token.py
How to get Google OAuth 2.0 access token in console using the Python API
View get_oauth2_token.py
#!/usr/bin/env python
'''
This script will attempt to open your webbrowser,
perform OAuth 2.0 authentication and print your access token.
To install dependencies from PyPI:
$ pip install oauth2client
Then run this script: