Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
REReplace( "your-string" , "\b(\S)(\S*)\b" , "\u\1\L\2" , "all" )
abaco
abbondanza
abbondanzia
abbondanzio
abbondazio
abbondia
abbondina
abbondio
abdenago
abdon
<!---
Parts of this are based on Tim Dawe's
http://amazonsig.riaforge.org
and
Joe Danziger's Amazon S3 REST Wrapper
http://amazons3.riaforge.org/
Written by Patrick Liess

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 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (non-clustered) requests per second and 30% CPU load, course, this was 2xIntel Xeon with HT 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.

First, you will need to install nginx, my way to install nginx is compiling it from source, but for now we will use apt-get

@ivanionut
ivanionut / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<!--- STEP 1 - ?event=shop-cart.cfm --->
<cfscript>
stDetails = structNew();
stDetails.cartTotal = 200.00;
stDetails.invoiceno = 3;
</cfscript>
<cfhttp url="https://api-3t.paypal.com/nvp" method="post">
<!--- auth --->
<cfhttpparam type="formfield" name="USER" value="#application.pp.username#" />
<cfscript>
/* ColdFusion 11 dropped the undocumented cfusion_encrypt & decrypt functions while Railo 4.2 still officially supports it.
This script will reestablish the built-in function. You can also use fusion_encrypt/decrypt (without the "c").
Based on 2005 blog post: http://www.barneyb.com/barneyblog/2005/10/28/cfusion_encryptcfusion_decrypt-udfs/ */
function fusion_binaryXOR(n1, n2){
n1 = formatBaseN(n1, 2);
n2 = formatBaseN(n2, 2);
return inputBaseN(replace(n1 + n2, 2, 0, "all"), 2);
}
function fusion_encrypt(string, key){
<cfscript>
/* Copy IsEMail.jar to java path. Download from https://code.google.com/p/isemail/downloads/list */
emails = ["[email protected]",
"[email protected]",
"[email protected]",
"""much.more unusual""@example.com",
"[email protected](comment)",
"""first\last""@iana.org",
"first.last@com",
"""Joe.\Blow""@iana.org",
<cfscript>
/* based on info from http://googlewebmastercentral.blogspot.com/2006/09/how-to-verify-googlebot.html */
badBot = 0;
blockBadBots = 0;
ip = cgi.remote_addr;
userAgent = CGI.Http_User_Agent;
/* Sample request values */
//userAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
//ip = "179.179.65.180"; //bad
<cfscript>
BadCookieList = [
"ASP.NET_SessionID",
"ISFIRSTVISIT",
"PHPSESSID",
"REMEMBERCOUNTRY",
"RESOURCEINFO",
"SESSIONS",
"SS_MID",
"USERINFO",