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 / linuxDateTime.cfc
Created May 9, 2016 09:31 — forked from randomweapon/linuxDateTime.cfc
create linux date time in coldfusion as well as convert epoch time back to a coldfusion date.
<cfcomponent>
<!---
Function Name : linuxDateTime()
Author : Ryan Spencer
Created : 26/09/2008
General Notes : Returns the date from a Epoch Time format of seconds
since UTC January 1, 1970, 00:00:00 (Epoch time).
@ivanionut
ivanionut / gist:1cf70179c5827678a8a9e7dae805b2bb
Created May 6, 2016 21:22 — forked from markbirbeck/gist:1684494
[ElasticSearch] Insert 5 records and query for a single record, with facets: Successfully returns a count of 1 in the facets
# Create an index:
#
curl -XDELETE 'http://127.0.0.1:9200/articles'
curl -XPUT 'http://127.0.0.1:9200/articles'
# Insert the action mapping, as a child of articles:
#
curl -XPUT 'http://127.0.0.1:9200/articles/article/_mapping' -d '
{
"article": {
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
// {"ok":true,"_index":"twitter","_type":"tweet","_id":"1","_version":1}
curl -XPOST localhost:9200/twitter/tweet/1/_update -d '{
"doc": {
@ivanionut
ivanionut / upload.cfc
Created May 3, 2016 15:32 — forked from jsteenkamp/upload.cfc
ColdFusion code for Plupload file uploading including chunked transfers
<cfcomponent>
<cffunction name="upload" access="remote" returntype="struct" returnformat="json" output="false">
<cfscript>
var uploadDir = expandPath('.') & '/uploads/'; // should be a temp directory that you clear periodically to flush orphaned files
var uploadFile = uploadDir & arguments.NAME;
var response = {'result' = arguments.NAME, 'id' = 0};
var result = {};
// if chunked append chunk number to filename for reassembly
if (structKeyExists(arguments, 'CHUNKS')){
@ivanionut
ivanionut / CfscriptFunctions.cfc
Created April 20, 2016 10:21
A ColdFusion component for using CFML functions within CF Script code blocks.
<!------------------------------------------------------------------------------
|| Component : CfscriptFunctions.cfc
|| Author : Jason Luttrell
|| Description : Provides a library of functions to be used by other CFCs.
|| Public Methods : cfabort
|| cfdump
|| cfhtmlHead
|| cfthrow
|| cfqueryofquery
|| etc...
@ivanionut
ivanionut / scrypt.cfm
Created April 18, 2016 08:31 — forked from brucekirkpatrick/scrypt.cfm
Using scrypt hashing in coldfusion or railo
<cfscript>
password="test1234";
N = 65536; // CPU cost parameter.
r = 16; // Memory cost parameter.
p = 1; // Parallelization parameter.
// Note: SCryptUtil has default of 16 byte random salt and 256-bit key
SCryptUtil=createobject("java", "com.lambdaworks.crypto.SCryptUtil", "/path/to/scrypt-1.4.0.jar");
// generate a hash
hashedPassword=SCryptUtil.scrypt(password, N, r, p);
query function getSpecialtyCodeChartData(required numeric rc=99){
var sc = queryExecute("Select specialtyname, qty From specialtycategorycount_view
Order by qty DESC, specialtyname",{},{maxrows = "#rc#"});
return sc;
}
public void function onError(required any exception, required string eventname){
//log error
writeLog(file='[LOG FILE NAME]', text='#arguments.exception.message#');
//save error information in a single variable
savecontent variable='errortext' {
writeOutput("An error occurred: http://#cgi.server_name##cgi.script_name#?#cgi.query_string#<br />
Time: #now().dateFormat('short')# :: #now().timeFormat('short')#<br />");
writeDump(var=arguments.exception, label='Error Log');
writeDump(var=form, label='Form Scope');
@ivanionut
ivanionut / gist:14fe0d06e427d5d5aa6ec46b2d93942a
Created April 9, 2016 18:39 — forked from ttezel/gist:6143316
Elasticsearch fuzzy search scores the same for exact match and non-exact match
curl -XPOST 'http://localhost:9200/fuzzytest/' -d '
{
settings: {
index: {
analysis: {
analyzer: {
default: {
type: "custom",
tokenizer: "uax_url_email",
filter: [ "lowercase" ]
@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>