Skip to content

Instantly share code, notes, and snippets.

Greg Nilchee gnilchee

  • Athlinks
  • Woodinville, WA
Block or report user

Report or block gnilchee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View foreach_tester.php
<?php
$array = array(
'fruit1' => 'apple',
'fruit2' => 'orange',
'fruit3' => 'grape',
'fruit4' => 'mango',
'fruit5' => 'peach');
echo $array['fruit3'];
echo "\n";
@gnilchee
gnilchee / memcache_tester.php
Created Sep 16, 2018
php and memcache example
View memcache_tester.php
<?php
$mem = new Memcached();
$mem->addServer("127.0.0.1", 11211);
$result = $mem->get("username");
if ($result) {
echo $result;
} else {
echo "No matching key found. I'll add that now!\n";
@gnilchee
gnilchee / nginx.conf
Created Sep 9, 2018
example nginx.conf with json logging (nginx 1.11.8+)
View nginx.conf
log_format json_combined escape=json
'{'
'"time_local":"$time_local", '
'"remote_addr":"$remote_addr", '
'"client_addr":"$proxy_add_x_forwarded_for", '
'"request_type": "$request_method", '
'"request":"$request", '
'"request_uri": "$uri", '
'"query_string": "$query_string", '
'"status": "$status", '
@gnilchee
gnilchee / es_6.3.0_stats_shards_20180618.json
Created Jun 19, 2018
GET /_stats?level=shards (ES v6.3.0)
View es_6.3.0_stats_shards_20180618.json
{
"_all": {
"primaries": {
"completion": {
"size_in_bytes": 0
},
"docs": {
"count": 1989994,
"deleted": 0
},
@gnilchee
gnilchee / git_describe_tags.py
Last active Jan 21, 2018
Get current tag of branch and increment patch version
View git_describe_tags.py
import git
git_path = '/path/to/git_dir/'
repo = git.Repo(git_path)
cur_version = repo.git.describe()
major, minor, patch = cur_version.split('.')
updated_patch = int(patch)+1
new_tag = '.'.join((major, minor, str(updated_patch)))
@gnilchee
gnilchee / ssh_command.py
Last active Jan 31, 2018
Simple example executing commands via ssh with Paramiko
View ssh_command.py
#!/usr/bin/env python
import paramiko
SSH_HOST='host.example.com'
SSH_USER='admin_user'
SSH_KEY='/home/user/.ssh/id_rsa'
def do_ssh_command(command):
try:
with paramiko.SSHClient() as client:
@gnilchee
gnilchee / autoscale_group_rotate.py
Last active Jan 24, 2018
Rotate out instances by bring up new instances making sure they are healthy and removing the old ones
View autoscale_group_rotate.py
#!/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 Jan 4, 2018
simple invoke script to clean and update apt-get
View tasks.py
#!/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 Oct 31, 2017
Crystal-Lang example using http/client, logger and option_parser
View site_checker.cr
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 Oct 2, 2017
Some simple get examples using SendGrid's REST against Github API
View rest_api.go
package main
import (
"fmt"
"encoding/json"
"github.com/sendgrid/rest"
)
func main() {
// var
You can’t perform that action at this time.