Skip to content

Instantly share code, notes, and snippets.

View justengland's full-sized avatar

Justin England justengland

View GitHub Profile
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
@justengland
justengland / gist:e637215934e961fbee23
Created April 30, 2015 06:39
SearchTwit searches
POST tweets/tweet/_search
{
"query": {
"match_all": {}
},
"sort": {
"postDate": {
"order": "desc"
}
/*global require, module*/
const ApiBuilder = require('claudia-api-builder');
const api = new ApiBuilder();
module.exports = api;
api.corsHeaders('Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Api-Version');
/* define a global function that returns an allowed cors origin. this will be used for the OPTIONS access-control-allow-origin response header */
api.corsOrigin(function (request) {
'use strict';
@justengland
justengland / install.sh
Last active July 23, 2016 23:51
How to create a jenkins slave on a AWS linux box. Add the jenkins-slave to /etc/init.d/jenkins-slave
sudo chkconfig --add jenkins-slave --level 2345
sudo chkconfig jenkins-slav on
chkconfig | grep jenkins-slave
@justengland
justengland / jenkins-script
Created July 24, 2016 04:34
Add mochawesome to jenkins
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'none'; script-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self'; style-src 'self'; font-src 'self';")
@justengland
justengland / promisifyAWS.js
Created January 19, 2017 21:38
Add promises to AWS methids
const cloudformation = new AWS.CloudFormation();
const describeStacks = promisifyAWS(cloudformation, 'describeStacks');
// Issue with AWS Code structure.
// Not bening fixed, but this should work for the methods I have seen.
// https://github.com/aws/aws-sdk-js/issues/278
function promisifyAWS(service, method) {
return function(params) {
return new Promise(function (resolve, reject) {
@justengland
justengland / get_cert.sh
Created April 10, 2017 16:12
Get Certificate info
#!/usr/bin/env bash
SITE=https://www.google.com;curl --insecure -v "$SITE" 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }'
@justengland
justengland / Notes
Last active October 18, 2017 03:47
Github Graphql
GraphQL Explorer
https://developer.github.com/v4/explorer/
Docs
https://developer.github.com/v4/
@justengland
justengland / mutatable.jsx
Created December 19, 2017 01:48 — forked from ctavan/mutatable.jsx
mutatable react HOC
import hoistNonReactStatic from 'hoist-non-react-statics';
import React from 'react';
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}
// See: https://facebook.github.io/react/docs/higher-order-components.html
export default function mutatable({ mutationName = 'mutate' } = {}) {
return (SourceComponent) => {
@justengland
justengland / promise-error.js
Created February 19, 2018 15:59
promise error example
function simulateSubmit (errorMessage) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (errorMessage) reject(new Error(errorMessage))
else resolve()
}, 2000)
})
}