Skip to content

Instantly share code, notes, and snippets.

View joshuacalloway's full-sized avatar

joshua calloway joshuacalloway

View GitHub Profile
@joshuacalloway
joshuacalloway / euler2.rb
Created June 22, 2018 21:45
euler problem 2 solution
=begin
This computes the answer to Euler problem 2 at https://projecteuler.net/problem=2
The solution takes advantage that
- every 3rd number in the sequence is even
- odd + odd = even
- even + odd = even
example below where [2], [8], [34], [144] are F3, F6, F9
aws> .profile jc@gmail
Current shell profile changed to: jc@gmail
aws> support describe-trusted-advisor-check-result --check-id eW7HH0l7J9 --query 'result.sort_by(flaggedResources[?statu
s!="ok"],&metadata[2])[].metadata' --output table --region us-east-1
A client error (AccessDeniedException) occurred when calling the DescribeTrustedAdvisorCheckResult operation: User: arn:aws:iam::952089433851:user/limitedTestUser is not authorized to perform: support:
aws> support describe-trusted-advisor-check-result --check-id eW7HH0l7J9 --query 'result.sort_by(flaggedResources[?statu
s!="ok"],&metadata[2])[].metadata' --output table --region us-east-1
A client error (SubscriptionRequiredException) occurred when calling the DescribeTrustedAdvisorCheckResult operation: AWS Premium Support Subscription is required to use this service.
@joshuacalloway
joshuacalloway / paginateawsusers.java
Last active July 26, 2016 21:56
aws identitymanagement paginate
ListUsersRequest request = new ListUsersRequest()
request.setMaxItems(20)
boolean moreUsers = true
List<User> users = new ArrayList<>()
while (moreUsers) {
ListUsersResult result = client.listUsers(request)
request.setMarker(result.getMarker())
users.addAll(result.getUsers())
moreUsers = result.isTruncated()
@joshuacalloway
joshuacalloway / DockerFileWithOpenCVAlpine
Created February 22, 2016 16:40
Docker file with opencv and alpine
FROM alpine
#2 Add Edge and bleeding repos
RUN echo -e '@edge http://nl.alpinelinux.org/alpine/edge/main\n@testing http://nl.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
#3
RUN apk update && apk upgrade && apk add --update \
python \
python-dev \
make \
cmake \
gcc \
@joshuacalloway
joshuacalloway / gist:caafac1003b38339897e
Created July 30, 2015 18:51
aws s3api upload lifecycle
BucketLifecycleConfiguration configuration1 = new BucketLifecycleConfiguration();
BucketLifecycleConfiguration.Rule rule = new BucketLifecycleConfiguration.Rule( );
rule.setExpirationInDays(1000);
configuration1 = configuration1.withRules(rule);
s3client.setBucketLifecycleConfiguration("", configuration1);
aws s3api put-bucket-lifecycle --bucket test-repository-tmp --lifecycle-configuration file://newrule.json
@joshuacalloway
joshuacalloway / spocktestEmbeddedMongoSpringBoot
Created June 12, 2015 19:03
first spock test with embedded mongo and spring boot
package com.shoppertrak.ssclogging
import com.mongodb.MongoClient
import de.flapdoodle.embed.mongo.MongodExecutable
import de.flapdoodle.embed.mongo.MongodProcess
import de.flapdoodle.embed.mongo.MongodStarter
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder
import de.flapdoodle.embed.mongo.config.Net
import de.flapdoodle.embed.mongo.distribution.Version
import de.flapdoodle.embed.process.runtime.Network
@joshuacalloway
joshuacalloway / gist:ae5b184c485956314d1c
Created March 3, 2015 00:28
simple React Hello trying to use React addons Perf. Throws undefined for count
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<title>Basic Example</title>
</head>
<body>
<h1>Basic Example 2</h1>
<div id="container"></div>
@joshuacalloway
joshuacalloway / SecureRequestCache
Created February 27, 2015 00:08
HowTo force Spring Security to make https redirect requests when behind a load balancer
package com.retel.security;
import org.springframework.security.web.PortResolver;
import org.springframework.security.web.PortResolverImpl;
import org.springframework.security.web.WebAttributes;
import org.springframework.security.web.savedrequest.DefaultSavedRequest;
import org.springframework.security.web.util.UrlUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@joshuacalloway
joshuacalloway / dockercopy.sh
Created September 26, 2014 18:33
simple docker copy directory doesn't work
mysqlidfull=$(docker run -e MYSQL_ROOT_PASSWORD=password -d mysql)
mysqlid=${mysqlidfull:0:4}
mysql=$(docker inspect $mysqlid | grep "Name" | grep "/" | sed 's/^.*\///g' | sed 's/".*$//g')
echo "mysql: ${mysql}"
docker cp ${mysql}:/var/lib/mysql .
@joshuacalloway
joshuacalloway / user-data
Created September 24, 2014 18:38
user-data
#cloud-config
coreos:
update:
group: alpha
reboot-strategy: best-effort
fleet:
public-ip: $private_ipv4
metadata: cloud=amazon,type=c3.large,spot=true,disk=64gb,subnet=public_retel,class=shoppertrak
etcd: