Skip to content

Instantly share code, notes, and snippets.

View fluential's full-sized avatar
💭
¯\_(ツ)_/¯

Mike fluential

💭
¯\_(ツ)_/¯
  • Earth
View GitHub Profile
@mboersma
mboersma / json2yaml
Last active March 8, 2023 10:31
JSON to YAML one-liner
python3 -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))'
@saml
saml / gmailexists.sh
Created March 31, 2012 20:39
gmail exists
#!/bin/bash
if (( $# < 1 ))
then
echo "Usage: $0 username"
exit 1
fi
username="$1"
json_left='{"input01":{"Input":"GmailAddress","GmailAddress":"'
@mendelgusmao
mendelgusmao / gist:2356310
Created April 11, 2012 01:53
high performance URL shortener on steroids using nginx, redis and lua
# based on http://uberblo.gs/2011/06/high-performance-url-shortening-with-redis-backed-nginx
# using code from http://stackoverflow.com/questions/3554315/lua-base-converter
# "database scheme"
# database 0: id ~> url
# database 1: id ~> hits
# database 2: id ~> [{referer|user_agent}]
# database 3: id ~> hits (when id is not found)
# database 4: id ~> [{referer|user_agent}] (when id is not found)
# database 5: key "count" storing the number of shortened urls; the id is generated by (this number + 1) converted to base 62
@dsc
dsc / jconsole-proxy.sh
Created August 7, 2012 01:15
jconsole via ssh proxy
#!/bin/bash
#/ jc -- jconsole via ssh proxy
#/
#/ Usage: jc [options] HOST JMX_PORT [PROXY_PORT=JMX_PORT] [JMX_HOST=HOST]
#/
#/ Starts a SOCKS proxy via ssh to connect to a
#/ JVM running on a remote and protected machine.
#/
#/ Arguments:
@scottjacobsen
scottjacobsen / git+clone+ssh+agent+forward+sudo
Created December 14, 2012 00:07
Git clone using ssh agent forwarding and sudo
SSH agent forwarding is great. It allows you to ssh from one server to
another all the while using the ssh-agent running on your local
workstation. The benefit is you don't need to generate ssh key pairs
on the servers you are connecting to in order to hop around.
When you ssh to a remote machine the remote machine talks to your
local ssh-agent through the socket referenced by the SSH_AUTH_SOCK
environment variable.
So you the remote server you can do something like:
@frimik
frimik / puppet-template-patterns.erb
Last active May 6, 2020 12:02
Puppet Template Patterns to remember.
## Check if variable is defined
# Replaces has_variable?(var) and if @var variations.
# include?() pattern from @Jan_vStone.
#
# scope.lookupvar return values for undefined variables:
# Puppet 3.x: nil
# Puppet 2.6.x: :undefined
# Puppet 2.7.x: :undefined
<% if ! [:undefined, nil, ''].include?(masquerade_address = scope.lookupvar('ftp::masquerade_address')) -%>
MasqueradeAddress <%= masquerade_address %>
@lavoiesl
lavoiesl / uniqueid.pp
Last active December 4, 2022 10:27
Puppet: Generate a unique integer id base on the hostname
#
# Generate a unique integer id base on the hostname
# It works by stripping $domain from the $::fqdn,
# removing all characters except alphanumeric and converting to base 10
# $domain is provided if you have complex domains like *.hosting.example.com
#
class uniqueid (
$domain = $::domain,
) {
$node_id = inline_template("<%= '$::fqdn'.gsub('$domain','').gsub(/[^a-z0-9]/i,'').to_i(36) %>")
@reifman
reifman / default.vcl
Last active September 9, 2021 08:15
Example Varnish VCL Configuration e.g. /etc/varnish/default.vcl
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 800;
}
node demo {
nagios::host::service { 'ping':
check_command => 'check_ping',
}
}
@xylifyx2
xylifyx2 / killparent.c
Last active July 7, 2016 08:26
Use in -XX:OnOutOfMemoryError="killparent"
#include <stdio.h>
#include <unistd.h>
int main()
{
printf ("kill -9 <parent>\n");
kill (getppid(), 9);
}