Skip to content

Instantly share code, notes, and snippets.

View chrisguitarguy's full-sized avatar

Christopher Davis chrisguitarguy

View GitHub Profile
<?php
namespace Some\Library;
interface LibraryException { }
class InvalidArgumentException extends \InvalidArgumentException implements LibraryException
{
// ...
}
FROM ubuntu:16.04
RUN apt-get update -y && apt-get -y install openssh-client
<?php declare(strict_types=1);
/*
* This file is part of pmg/core
*
* Copyright (c) PMG <https://www.pmg.com>.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#!/usr/bin/env python3
import argparse
import http.client as http
import os
import boto3 as aws
def _parse_args(args=None):
p = argparse.ArgumentParser(description='Update a hostname record in route53 with the current IP address')
p.add_argument('zone_id', help='The DNS zone id to update')
@chrisguitarguy
chrisguitarguy / policy.json
Created August 18, 2017 20:07
deny `PutObject` calls without KMS-based server side encryption.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyUnEncryptedOPutObject",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*",
"Condition": {
@chrisguitarguy
chrisguitarguy / .travis.yml
Created July 20, 2017 16:38
Example of how to conditionally run something on travis CI only on pull requests
script:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ./bin/dev/fixcs; fi'
@chrisguitarguy
chrisguitarguy / broken.js
Created April 28, 2017 18:08
Some wonky stuff can happen when you try to nest things inside `Router` components
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
function App({ children }) {
return <div>{children}</div>;
}
function Home() {
return <p>Hello, World</p>;
#!/usr/bin/env boot
(require '[clojure.string :as string])
(defn- str->int [s]
(Integer/parseInt s))
(defn- parse-line [line]
(map str->int (string/split line #"\s+")))
#!/usr/bin/env boot
(require '[clojure.string :as string])
(defn- str->int [s]
(Integer/parseInt s))
(defn- make-heights [s]
(let [is (map str->int (string/split s #"\s+"))
cs (map #(char (+ 97 %)) (range 26))]
#!/usr/bin/env boot
(require '[clojure.string :as string])
(defn- str->int [s]
(Integer/parseInt s))
(defn- round-grade [grade]
(let [r (mod grade 5)]
(if (>= r 3)