Skip to content

Instantly share code, notes, and snippets.

View gnilchee's full-sized avatar

Greg Nilchee gnilchee

  • Evernote
  • Woodinville, WA
View GitHub Profile
@gnilchee
gnilchee / autoscale_group_rotate.py
Last active January 24, 2018 07:29
Rotate out instances by bring up new instances making sure they are healthy and removing the old ones
#!/usr/bin/env python
import boto3
from time import sleep
from concurrent.futures import ProcessPoolExecutor, wait, as_completed
def get_asg_instances(asg_name):
'''
Responds with list of instance dictionaries that provides the following
:InstanceId - instance id
@gnilchee
gnilchee / tasks.py
Last active January 4, 2018 03:43
simple invoke script to clean and update apt-get
#!/usr/bin/env python3
from invoke import task
@task
def clean(ctx):
print("Cleaning!")
ctx.run("sudo apt-get clean all")
print("Cleaning Done.")
@task
@gnilchee
gnilchee / site_checker.cr
Created October 31, 2017 00:46
Crystal-Lang example using http/client, logger and option_parser
require "http/client"
require "option_parser"
require "logger"
destination = "changeme"
help = ""
log = Logger.new(STDOUT)
log.level = Logger::INFO
@gnilchee
gnilchee / rest_api.go
Created October 2, 2017 02:51
Some simple get examples using SendGrid's REST against Github API
package main
import (
"fmt"
"encoding/json"
"github.com/sendgrid/rest"
)
func main() {
// var
@gnilchee
gnilchee / output_to_html_with_syntax.go
Created September 25, 2017 00:57
Take multiline code in a variable and output to stdout html that has code in syntax highlighted in given format
package main
import (
"fmt"
"os"
"github.com/alecthomas/chroma/quick"
)
func main() {
my_code := `package main
@gnilchee
gnilchee / datadog_api_example.go
Created September 19, 2017 04:44
A few examples of different calls using zorkian's go datadog api library
package main
import (
"os"
"log"
"gopkg.in/zorkian/go-datadog-api.v2"
)
func main() {
// Get api and app key from environment var
@gnilchee
gnilchee / get_urls.py
Created September 4, 2017 05:06
python3 concurrency example with blocking requests
#!/usr/bin/env python
import requests
my_urls = [
'https://google.com/',
'https://youtube.com/',
'https://facebook.com/',
'https://wikipedia.org/',
'https://yahoo.com/',
'https://reddit.com/',
@gnilchee
gnilchee / ca-config.json
Created August 4, 2017 05:12
Create Your Own CA
{
"signing": {
"default": {
"expiry": "17520h"
},
"profiles": {
"2yr-server": {
"expiry": "17520h",
"usages": [
"signing",
@gnilchee
gnilchee / dd_stats_sender.py
Created July 1, 2017 00:44
send custom stats to datadog
#!/usr/bin/env python
from datadog import statsd
import requests
import time
def get_endpoint_status(url):
response = requests.get(url)
resp_time_miliseconds = response.elapsed.microseconds / 1000
result = {'status_code': response.status_code, 'response_time': resp_time_miliseconds}
return result
@gnilchee
gnilchee / hello_machine_learning.py
Last active June 30, 2017 03:28
Easy hello world machine learning example
#!/usr/bin/env python3
from sklearn import tree
###################
## Texture
# smooth = 1
# bumpy = 0
## label
# apple = 0
# orange = 1
##################