Skip to content

Instantly share code, notes, and snippets.

View mhuckaby's full-sized avatar
✌️
Ahoy hoy

Matthew Huckaby mhuckaby

✌️
Ahoy hoy
View GitHub Profile
@mhuckaby
mhuckaby / dev.conf
Created November 15, 2013 12:55 — forked from fnando/dev.conf
upstream tunnel {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name dev.codeplane.com br.dev.codeplane.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
@mhuckaby
mhuckaby / gist:8058932
Last active December 31, 2015 23:19
javascript factorial tail recursion
function f(n) {
return n === 0 ? 1 : n * f(n - 1);
}
@mhuckaby
mhuckaby / gist:11287726
Created April 25, 2014 12:20
find-the-nth-largest-number-in-an-array
// http://xorswap.com/questions/167-find-the-nth-largest-number-in-an-array
function testData() {
return [10, 1001, 15, 7, 33, 1001, 2, 0, 99, 131];
};
function sortAsc(a, b) {
if(a < b) {
return -1;
}else if(a === b) {
drawable/app_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/actual_pattern_image"
android:tileMode="repeat" />
values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
@Configuration
@EnableJpaRepositories(basePackages = "io.eddumelendez.springdatajpa.repository1")
public class FirstConfiguration {
@ConfigurationProperties(prefix = "datasource.postgres")
@Bean
@Primary
public DataSource postgresDataSource() {
return DataSourceBuilder.create().
build();
@mhuckaby
mhuckaby / gist:04ea5eb7ce3b50f9e469
Last active October 25, 2015 19:15
virtual box guest additions on centos 7
####
# For Centos 7
# iso
# https://www.centos.org/download/mirrors/
sudo yum update
sudo yum -y install gcc make gcc-c++ kernel-devel-`uname -r` zlib-devel openssl-devel readline-devel sqlite-devel perl wget dkms nfs-utils bzip2
sudo mkdir /mnt/cdv2
sudo mount -r -t iso9660 /dev/sr1 /mnt/cdv2
cd /mnt/cdv2
@mhuckaby
mhuckaby / setenv.sh
Created November 13, 2015 18:21 — forked from terrancesnyder/setenv.sh
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@mhuckaby
mhuckaby / elastic_beanstalk_external_sessions.md
Created February 15, 2016 03:39 — forked from mlconnor/elastic_beanstalk_external_sessions.md
Analaysis and recommendation for externalizing session in Elastic Beanstalk using Tomcat and memcached.

Session Management in an Autoscaling Environment

Problem Statement

User sessions in J2EE and LAMP stacks have traditionally been handled in memory by the application server handling the user request. Because of that, load balancers have been configured to use sticky sessions. By sticky sessions we mean that once the user has visited the site, they will be assigned an app server and will return to that server for subsequent requests. The load balancers typically handle that by referencing the users session cookie.

Elastic cloud environments differ from traditional server configurations in that they have a variable number of servers based on traffic loads whereas traditional configurations had a fixed number of servers. When traffic volumes decline it is necessary to vaporize servers. In doing so, we would lose user sessions (essentially forcing a logout) unless we come up with a new strategy for session management.

A new approach

After much research, it is clear that the best

# rxjs-extensions.js (same dir as app.module.ts)
// Observable class extensions
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
// Observable operators
import 'rxjs/add/operator/catch';