Skip to content

Instantly share code, notes, and snippets.

Avatar
🥑
avocado

Charlie Egan charlieegan3

🥑
avocado
View GitHub Profile
@charlieegan3
charlieegan3 / report.sh
Created Nov 10, 2020
Script to download data about the volume of resources in a cluster
View report.sh
#!/usr/bin/env bash
set -eo pipefail
OUTPUT_DIR=output
mkdir -p $OUTPUT_DIR
resources=($(kubectl api-resources | tail -n +2 | awk '{ print $1 }'))
ignore=("bindings" "tokenreviews" "localsubjectaccessreviews" "selfsubjectaccessreviews" "selfsubjectrulesreviews" "subjectaccessreviews")
View dropbox_content_hash.go
package dropbox
import (
"crypto/sha256"
"fmt"
"os"
"github.com/pkg/errors"
)
View semver_compare.rego
package semver_compare
is_greater_or_equal(a, b) = result {
result := {
is_greater(a, b),
is_equal(a, b),
} & { true } == { true }
}
is_lesser_or_equal(a, b) = result {
result := {
View each.sh
#!/usr/bin/env bash
# run safe_flatten for each in folder
set -eo pipefail
root_dir=$1
if [ -z "$root_dir" ]
then
View 1_download_film_data.rb
require "open-uri"
require "csv"
require "nokogiri"
require "pry"
csv_string = CSV.generate do |csv|
# this is the max number of pages with data on the-numbers.com
(1..5401).step(100).each do |page|
puts page
doc = Nokogiri::HTML(open("http://www.the-numbers.com/movie/budgets/all/#{page}").read)
@charlieegan3
charlieegan3 / urls.go
Last active Aug 17, 2017
url parsing fun
View urls.go
func main() {
// let's parse some youarells
url1, _ := url.Parse("http://www.example.com")
url2, _ := url.Parse("www.example.com")
// oops, this the second one needs a scheme, let's set one:
url2.Scheme = "http"
// perfect - now my urls are the same
fmt.Println(url1.String()) // => http://www.example.com
View main.go
package main
import (
"bytes"
"fmt"
"math/rand"
"os"
"os/exec"
"strconv"
"strings"
@charlieegan3
charlieegan3 / task.rb
Created Mar 6, 2017
github issue watcher
View task.rb
# intended for heroku daily scheduler
require "open-uri"
require "json"
require "pushover"
require "pry"
repos = {
"user/repo" => "tag"
@charlieegan3
charlieegan3 / Dockerfile
Created Jan 21, 2017
Dockerfile to run the coreNLP server.
View Dockerfile
FROM java:8
RUN curl http://nlp.stanford.edu/software/stanford-corenlp-full-2015-12-09.zip > corenlp.zip
RUN unzip corenlp.zip -d /corenlp
RUN mv /corenlp/*/* /corenlp
WORKDIR /corenlp
RUN export CLASSPATH="`find . -name '*.jar'`"
EXPOSE 9000
CMD java -cp "*" -mx4g edu.stanford.nlp.pipeline.StanfordCoreNLPServer
View data.json
[{"from":{"lat":"51.502500","lon":"-0.278126","name":"Acton Town"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":46.05,"legs":5},{"from":{"lat":"51.50856013","lon":"-0.262879534","name":"Acton Central"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":52.65,"legs":3},{"from":{"lat":"51.51394","lon":"-0.07537","name":"Aldgate"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":7.483333333333333,"legs":3},{"from":{"lat":"51.51514","lon":"-0.07178","name":"Aldgate East"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":10.8,"legs":3},{"from":{"lat":"51.54097","lon":"-0.30061","name":"Alperton"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":56.25,"legs":3},{"from":{"lat":"51.67435","lon":"-0.60732","name":"Amersham"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":75.75,"legs":5},{"from":{"lat":"51.53253","lon":"-0.10579","name":"Angel"},"to"