Skip to content

Instantly share code, notes, and snippets.

@zchee
zchee / cgo.md
Last active July 14, 2024 14:58
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@marvinpinto
marvinpinto / cleanup-ami.py
Created July 6, 2015 12:52
Python script to clean up and update the Jenkins AMIs after a successful Packer run
#!/usr/bin/python
import requests
import os
import boto.ec2
import sys
import re
build_url = os.environ['BUILD_URL']
jenkins_base_url = os.environ['JENKINS_URL']
@ginjo
ginjo / gist:aaa4a4395fcdbbad3d29
Last active December 1, 2019 08:32 — forked from bkimble/gist:1365005
Get structured array of hashes of memcached keys on multiple servers
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Forked from bkimble's gist https://gist.github.com/bkimble/1365005
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
# Currently resides at https://gist.github.com/ginjo/aaa4a4395fcdbbad3d29
#
# This fork separates the server query code from results presentation.
# The primary function of this script is to return an array of hashes of
# key items from any number of provided memcached servers.
@eklimcz-zz
eklimcz-zz / gist:446b56c0cb9cfe61d575
Created December 15, 2014 05:54
RSSI to Distance Conversion
function calculateDistance(rssi) {
var txPower = -59 //hard coded power value. Usually ranges between -59 to -65
if (rssi == 0) {
return -1.0;
}
var ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
@StephanieSunshine
StephanieSunshine / interfaces
Created October 8, 2014 10:13
Linode Debian / Ubuntu GRE tunnels hack /etc/network/interfaces
# One side, change the address by a digit and reverse the outside ip addresses for the other side
auto gre1
iface gre1 inet static
address 10.10.10.10 # inside side a address
netmask 255.255.255.0
pre-up ip tunnel add gre1 mode gre remote 173.230.145.76 local 173.230.147.224 #remote external ip local external ip
post-down ip tunnel del gre1
@ijin
ijin / consul_dynamic_inventory.rb
Created June 22, 2014 15:22
dynamic inventory script for ansible using consul
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
output = {}
s_json = JSON.parse(Net::HTTP.get_response(URI.parse('http://localhost:8500/v1/catalog/services')).body)
services = s_json.keys.reject{|k| k == 'consul'}
services.each do |srv|
@brb
brb / area14_2014_challenge_writeup.md
Last active November 23, 2020 14:35
area41 2014 challenge writeup

Intro

Being a cheapass student, I couldn't resist to try to win a free entrance to [Area41 Security Conference][3] (don't mix with Alcoholics Anonymous Area 41 in Nebraska) after spotting @gandro23 retweet about the conference and the challenge.

Level 01

The challenge starts after downloading and extracting a [binary][1]. A quick look

@jjmaestro
jjmaestro / whisper-calculator.py
Last active November 26, 2019 07:13
whisper-calculator.py: Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
@arangamani
arangamani / chef_attribute_converge.rb
Last active February 20, 2023 02:44
Dynamically update attribute of a Chef resource during converge phase (Node variable assignment in Compile vs Converge)
# In Chef, when a resource is defined all its variables are evaluated during
# compile time and the execution of the resource takes place in converge phase.
# So if the value of a particular attribute is changed in converge
# (and not in compile) the resource will be executed with the old value.
# Example problem:
# Let's consider this situation where there are two steps involved in a recipe
# Step 1 is a Ruby block that changes a node attribute. Rubyblocks get executed
# in converge phase
# Step 2 is a Chef resource that makes use of the node attribute that was
@louiszuckerman
louiszuckerman / as-terminate
Last active August 15, 2017 22:43
easy ssh access and pruning for EC2 instances in AutoScaling groups. depends on AWS CLI.
#!/bin/bash
if [ "$1" == "-h" ]; then
cat <<END
AWS AutoScaling Termination Helper:
terminate an instance in an auto scaling group
Usage: $0 {group-name}
END