Skip to content

Instantly share code, notes, and snippets.

View chapmandu's full-sized avatar

Adam Chapman chapmandu

View GitHub Profile
@JamoCA
JamoCA / limiter_UDF.cfm
Last active August 21, 2018 00:25
An update to a ColdFusion-based limiter UDF to throttle requests. Using HTTP status 429, CacheGet/Push (for automatic collection flushing) and cookie filters.
<cffunction name="limiter">
<!---
by Charlie Arehart, charlie@carehart.org, in 2009, updated 2012
http://www.carehart.org/blog/client/index.cfm/2010/5/21/throttling_by_ip_address
- Throttles requests made more than "count" times within "duration" seconds from single IP.
- sends 503 status code for bots to consider as well as text for humans to read
- also logs to a new "limiter.log" that is created automatically in cf logs directory, tracking when limits are hit, to help fine tune
- note that since it relies on the application scope, you need to place the call to it AFTER a cfapplication tag in application.cfm
- updated 10/16/12: now adds a test around the actual throttling code, so that it applies only to requests that present no cookie, so should only impact spiders, bots, and other automated requests. A "legit" user in a regular browser will be given a cookie by CF after their first visit and so would no longer be throttled.
- I also tweaked the cflog output to be more like a csv-format output
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active April 15, 2024 19:21
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@mlconnor
mlconnor / tomcat_memory.md
Created September 17, 2014 13:57
Memory settings for Java JVM in Amazon Elastic Beanstalk

Elastic Beanstalk Java JVM Settings

Determining the right memory settings (MX & MS) for the JVM is not trivial. If you set memory too low then your machine will trash as it runs out and eventually crash. If you set it too high then other critical processes such as Apache or the OS itself may become memory starved and also cause crashes.

In general, I think it best to set the initial memory setting (MS) to be small, around 200M. The real variable we need to calculate is the limit we will place on JVM memory (MS).

In order to make this determination, we need to calculate a few things such as the memory that Apache and the Linux OS need to operate efficiently.

Apache Memory Needs

@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active March 15, 2024 21:29
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@igal-getrailo
igal-getrailo / 1 nginx-railo.conf
Last active October 28, 2016 14:25
this is a reverse-proxy connector that connects nginx to Railo. the files in this example assume that they are located in the same folder as the nginx executable file (i.e. nginx.exe on Windows).the main conf file is nginx-railo.conf which should be passed to nginx as the config file, e.g. nginx -c nginx-railo.confit includes other config files …
#### this is the main config file for nginx, to specify it from the command line, use the -c switch, e.g
#### nginx.exe -c nginx-railo.conf
##** if connecting to Tomcat, use Tomcat's RemoteIpValve to resolve CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE
##** <Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto" remoteIpHeader="X-Forwarded-For" protocolHeaderHttpsValue="https" />
#user nobody;
#pid logs/nginx.pid;
@mschierberl
mschierberl / railo_cloudformation.json
Created September 19, 2012 04:07
Railo CloudFormation example with nginx
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to deploy railo4/tomcat7/nginx.",
"Parameters" : {
"KeyName" : {
"Default" : "bacfug",
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",