Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
<cfscript>
function convertQueryToStructArray( q ) {
var result = [];
for ( var row in arguments.q ) {
result.append( row );
}
return result;
}
@ivanionut
ivanionut / set-cookie.cfm
Created December 25, 2015 11:49 — forked from mikesprague/set-cookie.cfm
set cookie without cfcookie example (cfscript)
@ivanionut
ivanionut / create-data-uri.cfm
Created December 25, 2015 11:48 — forked from mikesprague/create-data-uri.cfm
CFML: Create Data URI
<cfscript>
function data_uri(fullFilePath, mimeType='image/*') {
var contents = fileReadBinary(fullFilePath);
var base64contents = toBase64(contents);
var returnString = "data:" & mimeType & ";base64," & base64contents;
return returnString;
}
</cfscript>
@ivanionut
ivanionut / gist:061f888ba83a8385d45f
Created December 25, 2015 11:47 — forked from mikesprague/gist:5706268
JavaScript: getRootWebSitePath
function getRootWebSitePath() {
var _location = document.location.toString();
var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3);
var applicationName = _location.substring(0, applicationNameIndex) + '/';
var webFolderIndex = _location.indexOf('/', _
location.indexOf(applicationName) + applicationName.length);
var webFolderFullPath = _location.substring(0, webFolderIndex);
return webFolderFullPath;
}
@ivanionut
ivanionut / Application.cfc
Created December 25, 2015 11:44 — forked from christierney402/Application.cfc
CF: Using "Access-Control-Allow-Origin" header in ColdFusion CFScript #snippet
component {
boolean function onRequestStart( required string targetPage ) {
var headers = getHttpRequestData().headers;
var origin = '';
var PC = getpagecontext().getresponse();
// Find the Origin of the request
if( structKeyExists( headers, 'Origin' ) ) {
@ivanionut
ivanionut / duplicity_backup.sh
Created November 30, 2015 15:16 — forked from dmp1ce/duplicity_backup.sh
Duplicity backup script
#!/bin/bash
# Backup all important files on my computer using Duplicity
# Folders to include
include_directories=(/home/me /etc)
# Folders to exclude
exclude_directories=()
@ivanionut
ivanionut / duplicity-backup.sh
Created November 30, 2015 15:11 — forked from moritzheiber/duplicity-backup.sh
Duplicity backup script
#!/bin/bash
#The MIT License (MIT)
#
#Copyright (c) 2014 Moritz Heiber <[email protected]>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
@ivanionut
ivanionut / dups3.sh
Created November 30, 2015 15:09 — forked from kblomqvist/dups3.sh
Duplicity backupper
#!/bin/sh
#
# Backuping
# ---------
# dups3 backup
#
# Restoring
# ---------
# dups3 restore /home/my/foo.txt ~/restore # Restore a file
# dups3 restore /home/my ~/restore # Restore a directory
@ivanionut
ivanionut / GraphicsMagick.cfm
Created November 12, 2015 11:02 — forked from JamoCA/GraphicsMagick.cfm
ColdFusion Custom Tag for GraphicsMagick. Faster than ColdFusion's CFImage/java processing. Smaller output files. Better CMYK compatibility. Works with more image formats. (Set timout=0 to have image manipulation performed in the background; 0ms)
<CFSETTING ENABLECFOUTPUTONLY="YES">
<!---
NAME: CF_GraphicsMagick
DESCRIPTION: ColdFusion wrapper for some GraphicsMagick routines. Faster than CFImage. Generates smaller images. Better
CMYK compatilibity (Adds compatibility to CF9.)
Works with more images formats, including EPS: http://www.graphicsmagick.org/formats.html
EXAMPLES:
<CF_GraphicsMagick action="AspectScale" Infile="#ImageIn#" Outfile="#imageOut#" width="#W#" height="#H#">
@ivanionut
ivanionut / code-1.cfm
Created November 8, 2015 16:27 — forked from ronnieduke/code-1.cfm
UPDATE: Parsing CSV Data Files In ColdFusion With csvToArray()
<cffunction
name="csvToArray"
access="public"
returntype="array"
output="false"
hint="I take a CSV file or CSV data value and convert it to an array of arrays based on the given field delimiter. Line delimiter is assumed to be new line / carriage return related.">
<!--- Define arguments. --->
<cfargument
name="file"