Skip to content

Instantly share code, notes, and snippets.

@dreadjr
dreadjr / TestPropertiesInjection.java
Created October 30, 2016 06:35 — forked from stantonk/TestPropertiesInjection.java
Example of loading a Java properties file and binding to @nAmed attributes in Guice. Handles default property settings as well. Adapted from code written by https://github.com/kylemcc
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
@dreadjr
dreadjr / golang-tls.md
Created October 20, 2016 04:34 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@dreadjr
dreadjr / seemailverify.java
Created October 6, 2016 00:04 — forked from tarun3kumar/seemailverify.java
Selenium email verification
public static void main(String[] args) throws Exception {
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "[email protected]",
"qwerty!@#$%");
Folder folder = store.getFolder("INBOX");
@dreadjr
dreadjr / etl.md
Created October 4, 2016 00:14 — forked from dannycoates/etl.md
AWS Lambda for ETL

Experimenting with AWS Lambda for ETL

A lot of us are interested in doing more analysis with our service logs so I thought I'd share an experiment I'm doing with Sync. The main idea is to transform the raw logs into something that'll be nice to query and generate reports with in Redshift.

The Pipeline

Pipeline Diagram

Logs make their way into an S3 bucket (lets call it the 'raw' bucket) where we've got a lambda listening for new data. This lambda reads the raw heka protobuf gzipped data, does some transformation and writes a new file to a different S3 bucket (the 'processed' bucket) in a format that is redshift friendly (like json or csv). There's another lambda listening on the processed bucket that loads this data into Redshift.

@dreadjr
dreadjr / webpack.config.js
Created July 26, 2016 07:24 — forked from wonderbeyond/webpack.config.js
webpack config for our complex RequireJS code base
var path = require('path');
var webpack = require('webpack');
var ModuleReplace = webpack.NormalModuleReplacementPlugin;
module.exports = {
entry: {
'zjs/js/zyb_transfer_launch': 'zjs/js/zyb_transfer_launch.js',
},
output: {
@dreadjr
dreadjr / example.js
Last active June 8, 2016 05:50 — forked from colingourlay/example.js
Lodash / Underscore sort object keys. Like _.sortBy(), but on keys instead of values, returning an object, not an array. Defaults to alphanumeric sort.
var obj = {b: 3, c: 2, a: 1};
_.sortKeysBy(obj);
// {a: 1, b: 3, c: 2}
_.sortKeysBy(obj, function (value, key) {
return value;
});
// {a: 1, c: 2, b: 3}
@dreadjr
dreadjr / picturelife-request-zips.js
Created May 24, 2016 19:57
Picturelife request zip download files
console.log("https://picturelife.com/account/my_archive?include_metadata=true");
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
function downloadAll() {
jQuery('form[action="/zips/download"]').each(function(i, f) {
var postData = {
taken_at_start: f["taken_at_start"].value,
@dreadjr
dreadjr / global.js
Created April 30, 2016 07:05 — forked from katowulf/global.js
Overriding error handling in AngularFire by extending and decorating $$error
// this will remove all error logging globally
angular.config(function($provide) {
$provide.decorator("$firebaseObject", function($delegate) {
$delegate.prototype.$$error = function(err) {
this.$destroy(err);
};
return $delegate;
});
$provide.decorator("$firebaseArray", function($delegate) {
@dreadjr
dreadjr / gist:18ae049ccdcd73550de23f6de5bcdecb
Created April 28, 2016 00:00 — forked from tschellenbach/gist:b0f1cf65647cb0acd0ef
GetStream.io aggregated notification feed example
# Instantiate a new client
import stream
client = stream.connect('key', 'secret')
# Assume the notification is aggregated on
# {% if verb.infinitive == 'like' %}{{ object }}{% else %}{{ id }}{% endif %}
notification_feed = client.feed('notification', '1')
# Add two likes, one comment and two follows
activities = [
@dreadjr
dreadjr / aws-sns-example.js
Last active April 13, 2016 23:19 — forked from tmarshall/aws-sns-example.js
aws-sdk sns example, in Node.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();