Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
@ivanionut
ivanionut / gist:8f4067abe41ae4126d0c
Created March 28, 2016 15:50 — forked from phillro/gist:1193227
Elasticsearch autocomplete example with cross origin resource sharing
<html>
<head>
<link rel="stylesheet" href="/examples/stylesheets/ui-lightness/jquery-ui-1.8.16.custom.css" type="css">
<script type="text/javascript" src="/examples/javascripts/jquery.min.js"></script>
<script type="text/javascript" src="/examples/javascripts/jquery.base64.min.js"></script>
<script type="text/javascript" src="/examples/javascripts/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/examples/javascripts/jquery.tmpl.min.js"></script>
</head>
<body>
@ivanionut
ivanionut / Exiv2_UDF.cfm
Created March 11, 2016 08:57 — forked from JamoCA/Exiv2_UDF.cfm
ColdFusion wrapper for Exiv2.exe (a command line utility to extract EXIF data). Much faster than ImageGetEXIFMetaData().
<!--- 2/16/2016 Exiv2(filePath, ExePath)
James Moberg - SunStar Media
Requires command-line version of Exiv2 http://www.exiv2.org/
All data returned in a struct. Based on filetype & metadata, keys may not always exist.
Latitude/Longitude keys w/decimal values added. All dates formatted to M/D/YYYY HH:MM:SS format.
Similar to ImageGetEXIFMetaData(imageNew( imageFilePath )), but much faster. (Exiv2 = 16-47ms; CF = 500-920ms)
--->
<cffunction name="Exiv2" returntype="struct" output="no">
<cfargument name="filepath" type="string" required="true">
<cfargument name="EXEpath" default="C:\Exiv2\Exiv2.exe" type="string" required="false">
@ivanionut
ivanionut / JsoupTableParse.cfm
Created March 11, 2016 08:52 — forked from JamoCA/JsoupTableParse.cfm
Sample ColdFusion script to parse a webpage and extract table data using jsoup.
<cfhttp url="http://target_website_with-table.com/" username="#CGI.Http_User_Agent#"></cfhttp>
<cfscript>
jsoup = CreateObject("java", "org.jsoup.Jsoup");
HTMLDocument = jsoup.parse(CFHTTP.fileContent);
/* Identify a specific table containing the data to scrape */
TheTable = HTMLDocument.select("##tableByID");
/* Alternate DOM select methods if table doesn't have a unique ID
@ivanionut
ivanionut / index.cfm
Created February 25, 2016 09:24 — forked from s992/index.cfm
Integrating SendGrid with CF
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>SendGrid Demo</title>
</head>
<body>
<form action="process.cfm" method="POST">
<div>
<label for="emails">
@ivanionut
ivanionut / etc-nginx-conf.d-observium.conf
Created February 18, 2016 10:23 — forked from oogali/etc-nginx-conf.d-observium.conf
Observium Nginx configuration
server {
listen 80;
server_name observium.yourdomain.com;
access_log /var/log/nginx/observium-access_log combined;
error_log /var/log/nginx/observium-error_log warn;
root /opt/observium/html;
client_max_body_size 10m;
client_body_buffer_size 8K;
<cfscript>
/**
* Displays a formatted approximation of how long ago a timestamp was.
*
* @param input - Date to Format (required)
* @param defaultMask - the date mask if the date is earlier than the earliest case. Default dd MMM, YYYY
* @return Returns a string.
* @author Ryan Guill ([email protected]), Adam Tuttle ([email protected])
* @version 1, Sept 11, 2014
@ivanionut
ivanionut / barcode4j.cfm
Created February 15, 2016 16:48 — forked from paulklinkenberg/barcode4j.cfm
barcode4j example in CFML / Lucee
<cfset jarsPath = expandPath('/java/barcode4j/') />
<!--- Path where the necessary jar files are located (downloadable from https://www.dropbox.com/s/skl9fwky2n7mnjr/java-files-barcode4j.zip?dl=0) --->
<cfset libraryList = arrayToList( directoryList(jarsPath, false, 'array', '*.jar') ) />
<cfset configBuilder = createObject('java', 'org.apache.avalon.framework.configuration.DefaultConfigurationBuilder', libraryList) />
<cfset barcodeUtil = createObject('java', 'org.krysalis.barcode4j.BarcodeUtil', libraryList) />
<cfset grayImageType = createObject('java', 'java.awt.image.BufferedImage').TYPE_BYTE_GRAY />
<!--- create custom config. See http://barcode4j.sourceforge.net/2.1/symbol-ean-13.html --->
<cfset configXml = '<barcode>
@ivanionut
ivanionut / UDF_isWebCEO.cfm
Created February 10, 2016 18:31 — forked from JamoCA/UDF_isWebCEO.cfm
Identify WebCEO Bot Request - Block unwanted page requests from automated Competitor Metrics & Backlink Spy (They don't provide a way for sites to opt-out or use WebCEO-specific robots.txt rules.)
<cfscript>
/* 1/4/2016 Identify WebCEO Bot Request (https://www.webceo.com/webceo-bots.htm)
Block unwanted page requests from automated Competitor Metrics & Backlink Spy (They don't provide
a way for sites to opt-out or use WebCEO-specific robots.txt rules.)
*/
function isWebCEO(){
return YesNoFormat(ListFind("97.107.131.214,69.164.220.17,69.164.220.10,69.164.208.136,69.164.208.68,97.107.135.120,97.107.135.14,69.164.212.131,97.107.133.236,97.107.131.160", CGI.Remote_Addr) OR Findnocase("seo-audit-check-bot", CGI.http_User_Agent) OR Findnocase("online-webceo-bot", CGI.http_User_Agent));
}
</cfscript>
@ivanionut
ivanionut / limiter_UDF.cfm
Created February 10, 2016 18:30 — forked from JamoCA/limiter_UDF.cfm
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, [email protected], 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noodp, noydir" />
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<link rel="canonical" href="http://mysite.com/" />
<link rel="stylesheet" href="http://mysite.com/style.css" type="text/css" />