Skip to content

Instantly share code, notes, and snippets.

@ruseel
ruseel / gist:26e98aea480f8c2138fa070c5f3930fc
Created September 21, 2018 01:34
hadoop-aws test output
[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 August 1, 2018 09:56
scala - google storage transfer job create
#
# 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 August 1, 2018 07:49
Google AdSense API with ServiceAccount - Not possible
@ruseel
ruseel / googe_spreadsheet_v4_append.java
Last active March 16, 2018 07:43
spreadsheet.values.append java example
// 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 October 11, 2017 05:18 — forked from clarketm/get_oauth2_token.py
How to get Google OAuth 2.0 access token in console using the Python API
#!/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:
@ruseel
ruseel / parquet.clj
Created March 29, 2017 06:20
parquet clojure without mr
;; writer
(ParquetWriter. path (ThriftWriteSupport. clazz))
;; reader
(ParquetReader. (Configuration.) path (ThriftReadSupport. clazz))
;; reader with filter
(ParquetReader. (doto (Configuration.)
(.set ThriftReadSupport/THRIFT_COLUMN_FILTER_KEY "eventId;eventName;actType;clientId;ifa;dt"))
@ruseel
ruseel / gist:e99ae451ef4f91f912d6adf4e3e93bc5
Created February 24, 2017 09:57
aws cli get PublicNnsName by tag 'Name'
aws ec2 describe-instances --query "Reservations[*].Instances[*][].{dns: PublicDnsName, name: Tags[?Key=='Name'].Value|[0]} | [?name=='af3-fluentd-prod'] | [].dns" | jq -r '.[]' | ruby -ne 'puts $_ if $_.strip != ""'
(requrie 'org.jclouds.blobstore2)
(alias 'b 'org.jclouds.blobstore2)
(def ^:dynamic *blobstore*
(b/blobstore
"aws-s3"
ACCESS_KEY
ACCESS_SECRET_KEY
"jclouds.endpoint" "http://s3-ap-southeast-1.amazonaws.com"))
public class NamedParamStatement {
public NamedParamStatement(Connection conn, String statementWithNames) throws SQLException {
Pattern findParametersPattern = Pattern.compile("(?<!')(:[\\w]*)(?!')");
Matcher matcher = findParametersPattern.matcher(statementWithNames);
while (matcher.find()) {
fields.add(matcher.group().substring(1));
}
prepStmt = conn.prepareStatement(statementWithNames.replaceAll(findParametersPattern.pattern(), "?"));
}
@ruseel
ruseel / a.clj
Created December 2, 2016 05:25
clj-http로 keep-alive를 이용해서 요청하기
(time (doseq [conn-mgr [(clj-http.conn-mgr/make-reusable-conn-manager {})]]
(dotimes [_ 2]
(clj-http.client/request {:method :get
:url "https://www.valuepotion.com/"
:connection-manager conn-mgr})
nil)))