Skip to content

Instantly share code, notes, and snippets.

View stevenscg's full-sized avatar

Chris Stevens stevenscg

View GitHub Profile
@lrytz
lrytz / z-automator.png
Last active October 15, 2024 06:31
Shortcut for Syntax Highlighting in Keynote
@niyazpk
niyazpk / pQuery.js
Created October 25, 2014 14:03
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@schlomo
schlomo / aws_mfa.sh
Created September 18, 2014 09:03
Helper Bash function to set up temporary AWS credentials for MFA protected accounts.
function aws_mfa {
if [[ -z "$AWS_ACCESS_KEY_ID" ]] ; then
echo "Please set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"
return 1
fi
if [[ -z "$REAL_AWS_ACCESS_KEY_ID" ]] ; then
REAL_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
REAL_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
fi
<?php
App::uses('DispatcherFilter', 'Routing');
/**
* Api Cors Dispatcher
*/
class ApiCorsDispatcher extends DispatcherFilter {
public $priority = 1;
@oroce
oroce / README.md
Created June 12, 2014 07:51
nginx request id
@progrium
progrium / consulkv
Created June 4, 2014 22:21
Consul KV client, depends on jq
#!/bin/bash
CONSUL="localhost:8500"
main() {
case "$1" in
info)
curl -s "$CONSUL/v1/kv/$2" | jq -r .[]
;;
get)
@hostmaster
hostmaster / authorized_keys.j2
Last active August 2, 2021 20:02
Purge unmanaged keys from ~/.ssh/authorized_keys , keep only listed public keys
# {{ ansible_managed }}
{% for key in pub_keys.results %}
{{ key.stdout }}
{% endfor %}
@denji
denji / nginx-tuning.md
Last active April 17, 2025 07:26
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@mtowers
mtowers / README.md
Last active February 26, 2020 16:34
A Dashing dashboard widget for displaying a graph of metrics data from Librato

Description

A Dashing widget for displaying a graph of metrics data from Librato

Dependencies

httparty

Add it to dashing's gemfile:

@tim-peterson
tim-peterson / UploadHandlerS3.php
Last active October 18, 2024 11:39
jQuery-File-Upload S3 PHP upload directly using AWS PHP SDK V2 (w/ optional Dropbox Chooser-selected files) https://github.com/blueimp/jQuery-File-Upload
<?php
use Aws\Common\Aws;
use Aws\S3\Exception\S3Exception;
// make sure the SDK is installed
// I've used Composer to autoload it: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html
/*
* jQuery File Upload Plugin PHP Class 7.1.0
* https://github.com/blueimp/jQuery-File-Upload