Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / install-git-completion.sh
Created December 9, 2016 19:42 — forked from johngibb/install-git-completion.sh
Mac OS X - Install Git Completion
URL="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
PROFILE="$HOME/.profile"
echo "Downloading git-completion..."
if ! curl "$URL" --silent --output "$HOME/.git-completion.bash"; then
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1
fi
@dreadjr
dreadjr / pr.md
Created January 3, 2017 18:44 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@dreadjr
dreadjr / wget on osx sierra
Last active February 7, 2017 05:38 — forked from burakerdem/gist:d8195e6e343aa55ff578
Installing wget on Mac OS X El Capitan 10.11
curl -O http://ftp.gnu.org/gnu/wget/wget-1.17.tar.gz
tar -xzf wget-1.17.tar.gz
cd wget-1.17
ln -s /usr/local/opt/openssl /usr/local/ssl
./configure --with-ssl=openssl
./configure --with-ssl=openssl --with-libssl-prefix=/usr/local/ssl
make
sudo make install
wget --help
cd .. && rm -rf wget*
@dreadjr
dreadjr / dynFib.js
Created February 7, 2017 19:38 — forked from mlhaufe/dynFib.js
Dynamic Programming with Fibonacci
//More info: <https://thenewobjective.com/blog/2013/01/dynamic-programming-for-great-justice/>
// Imperative: O(n) time, O(1) space
function fib(n){
if(n < 2)
return n;
var f0 = 0, f1 = 1, f;
for(var i = 1; i < n; i++){
@dreadjr
dreadjr / index.md
Created February 24, 2017 02:27 — forked from alexcasalboni/index.md
Bridge Function between Kinesis Streams and Step Functions

Bridge Function between Kinesis Streams and Step Functions

For each record read from the Kinesis Stream, a StepFunction state machine will be executed asynchronously.

Required Environment Variables

  • region: the AWS region where your StepFunction state machine is defined.
  • stateMachineArn: the ARN of the StepFunction state machine you want to execute.

Notes

@dreadjr
dreadjr / twitter_update_with_media.coffee
Created March 10, 2017 21:40
Node.js module for basic Twitter update_with_media support. You will need to install 'request' packages from npm like so: npm install request
fs = require('fs')
path = require('path')
request = require('request')
class twitter_update_with_media
constructor: (@auth_settings) ->
@api_url = 'https://api.twitter.com/1.1/statuses/update_with_media.json'
post: (status, file_path, callback) ->
r = request.post(@api_url, oauth:@auth_settings, callback)
// change group currency task registration
export let changeGroupCurrency = functions
.database
.ref('/serverTasks/currencyChange/{taskId}')
.onWrite(event => changeGroupCurrency(event));
// function which changes group's currency and updates exchange rates of all expenses
async function changeGroupCurrency(event: Event<DeltaSnapshot>)
{
// prevent triggering this function after writing response code