Skip to content

Instantly share code, notes, and snippets.

@chrisgilmerproj
chrisgilmerproj / gist:1435738
Created December 5, 2011 22:40
Simple mode code
float mode(float *data_array){
int c_new, c_old = 0, 0;
float mode_new, mode_old = 0.0, 0.0;
int i;
for(i = 0; i < len(data_array); i++){
float num = data_array[i]
if (num != mode_new) {
if (c_new > c_old) {
c_old = c_new;
mode_old = mode_new;
@chrisgilmerproj
chrisgilmerproj / gist:1503913
Created December 21, 2011 00:14
Password Generator
p = ''.join(random.sample('ABCDEFGHJKLMNPQRSTUVWXYZ23456789', 6))
def ip2hex(ip):
return ":".join(map(lambda x: hex(int(x))[2:].zfill(2), ip.split(".")))
def ip2hex(ip):
return ":".join(map(lambda x: "%02x" % int(x), ip.split(".")))
@chrisgilmerproj
chrisgilmerproj / gist:4241281
Created December 8, 2012 18:42
Django Settings Header
import os.path
import sys
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
# Include apps on the path
sys.path.insert(0, os.path.join(PROJECT_ROOT, "apps"))
@chrisgilmerproj
chrisgilmerproj / gist:11378074
Created April 28, 2014 17:09
Angularjs UI modal question
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" ng-model='query'>
<span class="input-group-btn">
<button type="button" class="btn btn-info" ng-click="search()">Search</button>
</span>
</div>
$scope.search = function () {
### Keybase proof
I hereby claim:
* I am chrisgilmerproj on github.
* I am cgilmer (https://keybase.io/cgilmer) on keybase.
* I have a public key ASD5YOIixMd6RTpDPS3wSYnF2E8DXLAPtN-WJfs_pb-eOwo
To claim this, I am signing this object:
@chrisgilmerproj
chrisgilmerproj / gist:ce285bf317c02e23231be6a3e6de5e04
Created November 18, 2016 17:45
Slack Python Incomming Webhook API
import re
import requests
DEFAULT_TIMEOUT = 10
class IncomingWebhook(object):
"""
https://api.slack.com/incoming-webhooks

Keybase proof

I hereby claim:

  • I am chrisgilmerproj on github.
  • I am cgilmer (https://keybase.io/cgilmer) on keybase.
  • I have a public key whose fingerprint is 47CE A5ED 26BC FA2E 8960 E84E 9B9B 5634 A88A B754

To claim this, I am signing this object:

@chrisgilmerproj
chrisgilmerproj / gist:edaea5c4f421b6f3b7c0d4bbabb2e894
Created March 28, 2022 20:12
Debug for Terraform aws_iam_policy_document
This file has been truncated, but you can view the full file.
2022-03-28T13:12:00.222-0700 [INFO] Terraform version: 1.1.7
2022-03-28T13:12:00.222-0700 [INFO] Go runtime version: go1.17.2
2022-03-28T13:12:00.222-0700 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/2.2.3/versions/1.1.7/terraform", "plan"}
2022-03-28T13:12:00.222-0700 [DEBUG] Attempting to open CLI config file: /Users/cgilmer/.terraformrc
2022-03-28T13:12:00.222-0700 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2022-03-28T13:12:00.222-0700 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2022-03-28T13:12:00.222-0700 [DEBUG] ignoring non-existing provider search directory /Users/cgilmer/.terraform.d/plugins
2022-03-28T13:12:00.222-0700 [DEBUG] ignoring non-existing provider search directory /Users/cgilmer/Library/Application Support/io.terraform/plugins
2022-03-28T13:12:00.222-0700 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2022-03-28T13:12:00.223-0700 [INFO] CLI command args: []string{"plan"}