Skip to content

Instantly share code, notes, and snippets.

@keith-miller
keith-miller / oauth_example.erl
Created May 30, 2012 18:00
OAuth post example
oauth_post(header, URL, Params, Consumer, Token, TokenSecret, Realm, Domain) ->
Signed = oauth:sign("POST", URL, Params, Consumer, Token, TokenSecret),
{AuthorizationParams, QueryParams} = lists:partition(fun({K, _}) -> lists:prefix("oauth_", K) end, Signed),
Request = {oauth:uri(URL, QueryParams), header(AuthorizationParams, Domain, Realm),
"application/x-www-form-urlencoded", ""},
httpc:request(post, Request, [{autoredirect, false}], [{headers_as_is, true}]).
header(Params, Domain, Realm) ->
RealmHeader = string:concat(string:concat("OAuth realm=\"", Realm), "\", "),
[{"Host", Domain},
@keith-miller
keith-miller / login.erl
Created June 1, 2012 15:53
OAuth login example
%% log in with the request token
%% will return the verifier
login(LoginUrl, User, Pass, RequestToken, Domain) ->
PostData = build_post_data([
{"email", User},
{"password", Pass},
{"oauth_token", RequestToken}
]),
Request = {LoginUrl, [], "application/x-www-form-urlencoded", PostData},
%% turn on cookies
@keith-miller
keith-miller / gist:5449287
Last active December 16, 2015 14:29
Fixed the missing first chunk problem. This is working.
fire_http_request (URL, Method, ReqData, State) ->
%% ... prep code here
Options = [{connect_timeout, TimeoutMs},
{max_sessions, MaxConn},
{response_format, binary},
{stream_to, {self(), once}}],
case ibrowse:send_req(URL, ReqLHeadersHost, Method, ReqLBody, Options) of
{ibrowse_req_id, ReqId} ->
case ibrowse:stream_next(ReqId) of
@keith-miller
keith-miller / gist:df2e89d0bf97951290f6
Last active August 29, 2015 14:06
Play 2.x service script
#!/bin/sh
DESC="Play application service"
NAME=play-application-service
PIDFILE=/opt/$NAME/RUNNING_PID
# result of operation
result=0
# Load the helper fuctions
@keith-miller
keith-miller / gist:bda4cf25a223e6fce616
Last active August 29, 2015 14:06
Play 2.x app.args example
#!/bin/sh
APP_ARGS="-Dhttp.port=8000 -Xmx512M -Xms128M -XX:PermSize=256m -XX:MaxPermSize=256m"
@keith-miller
keith-miller / user-data.sh
Last active February 27, 2024 17:28
User data script to join an Ubuntu 16.04 EC2 instance to an Active Directory domain
#!/bin/bash
set -ex
# parameters
DOMAIN_CONTROLLER=
DOMAIN_CONTROLLER_IP=
AD_HOST=
BASE_DN=
S3_BUCKET=
# separate domains with a space
11-20 01:54:11.128: W/Tycho(16840): [973] bm.b: Error executing activateSubscription()
11-20 01:54:11.128: W/Tycho(16840): SwitchingException code=UICC_LOGICAL_CHANNEL_UNSUCCESSFUL_STATUS mUiccResponseStatus=6985 desc=Unsuccessful return code. openLogicalChannelStatus=1 internalException=null
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.util.bk.a(SourceFile:258)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.util.bk.a(SourceFile:171)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.b.a.a.a(SourceFile:7225)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.g.d.a(SourceFile:125)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.g.f.a(SourceFile:50227)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.g.f.a(SourceFile:819)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.g.f.a(SourceFile:43557)
11-20 01:54:11.128: W/Tycho(16840): at com.google.android.apps.tycho.s
@keith-miller
keith-miller / DataSourceConfiguration.java
Created January 23, 2018 01:10
DropWizard HealthCheck with Spring Boot
@Configuration
public class DataSourceConfiguration {
@Autowired
private WebApplicationContext context;
@Value("${spring.datasource.url}")
private String url;
@Value("${spring.datasource.username}")
private String username;
pipeline {
agent none
options {
disableConcurrentBuilds()
}
stages {
stage('checkout_repo') {
agent {