Skip to content

Instantly share code, notes, and snippets.

View boris317's full-sized avatar

Shawn Adams boris317

View GitHub Profile
export function renderComponent(component, query, variables) {
let {loading, error, data} = useQuery(query, {variables});
if (loading) {
return null;
}
if (error) {
console.log(error);
}
class AirBookingService {
private final Database db;
private final BookingService bookings;
private static final Map<String, User> userCache = new HashMap<>();
public AirBookingService() {
db = new Database();
bookings = BookingServiceFactory.getService();
}
@boris317
boris317 / foo.js
Created September 12, 2018 13:48
POST with ajax
$("#newDeviceForm").submit(function(e) {
// Don't let the browser submit automatically
e.preventDefault();
$.ajax({
type: "POST",
url: "http://rad8prod-env.paxsdtgzng.us-east-1.elasticbeanstalk.com/devices",
headers: {
Authorization: "dev_env_pw"
},
data: this.serialize(),
let plugins = getPlugins()
.flatMap(p => p)
// Group plugins by consumer_id or app_id
.reduce((obj, p) => {
let id = p.consumer_id || p.api_id;
if (id in obj) {
obj[id].push(p);
} else {
obj[id] = [p];
}
Shawn's Intellij Shortcuts
Symbols:
⌥ Option
⌘ Command
⇧ Shift
⌃ Control
← Left arrow
→ Right Arrow
↑ Up Arrow
@boris317
boris317 / test.js
Created July 29, 2016 01:32
RXJS Chaining HTTP Calls
var http = require('http');
var RX = require('rx');
var request = require('request');
function get(url) {
return RX.Observable.create(function(observer) {
request(url, function(err, response, body) {
if (err) {
observer.onError(err);
return;
#!/usr/bin/env python
import sys
print "\\n".join([l.strip() for l in sys.stdin.readlines()])
@boris317
boris317 / statsd-tcpdump.sh
Last active November 14, 2017 16:43
Verify data is being fed to collectd and statsd
# statsd
sudo tcpdump -i eth0 -p -n -s 1500 -A udp port 8125
# statsd flushing to graphite
sudo tcpdump 'port 2005 or 2009' -s0 -A
# collectd
sudo tcpdump -i eth0 -p -n -s 1500 -A udp port 25827
@boris317
boris317 / install-packer.sh
Created May 16, 2015 14:50
Running packer from source (OSX)
#!/bin/bash
# Usage: $ ./install-packer.sh
brew install golang
# Create go workspace dir
mkdir ~/golang
cat << EOF > ~/.bashrc
# Golang
export GOPATH=$HOME/golang
@boris317
boris317 / gist:28ca0ce271118bad51bb
Created March 26, 2015 15:12
P4 get the diff of a change list
# p4 diff by changelist
function p4d {
if [ "$1" == "" ]
then
echo "usage: p4d CL";
return 1;
fi
p4 opened -c $1 | sed -e 's/#.*//' | p4 -x - diff -du | less
}