Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
<cfscript>
num_iterations = 1*1000*1000;
start_time = getTickCount();
for(i=1; i<=num_iterations; i++) test();
end_time = getTickCount();
tot_time = end_time - start_time;
writeOutput("#tot_time#ms");
@ivanionut
ivanionut / QoQ.cfm
Last active September 7, 2018 20:32
<cfscript>
max=10000;
persons = queryNew(
"lastname, firstname",
"cf_sql_varchar, cf_sql_varchar",
[
[ "Lebowski", "Jeffrey" ],
[ "Lebowski", "Bunny" ],
[ "Lebowski", "Maude" ],
@ivanionut
ivanionut / nginx.conf
Created August 19, 2018 12:08 — forked from igortik/nginx.conf
Nginx optimized configuration with DDoS mitigation
user nginx;
# one(1) worker or equal the number of _real_ cpu cores. 4=4 core cpu
worker_processes 4;
# renice workers to reduce priority compared to system processes for
# machine health. worst case nginx will get ~25% system resources at nice=15
worker_priority -5;
<cfscript>
cftimer(label = "UnScoped", type = "outline"){
for (i = 1; i LTE 1000000; i++){
_site.foo = "";
}
}
cftimer(label = "Scoped", type = "outline"){
<cfscript>
function prettyPrintJSON (inputJSON) {
var engine = createObject("java","javax.script.ScriptEngineManager").init().getEngineByName("nashorn");
engine.eval("
function prettyPrintJSON (data) {
return JSON.stringify(JSON.parse(data), null, '\t');
}
");
return engine.invokeFunction("prettyPrintJSON", [inputJSON]);
}
<cfscript>
people = QueryNew( "name,dob,age", "varchar,date,int", [
[ "Susi", CreateDate( 1970, 1, 1 ), 0 ],
[ "Urs" , CreateDate( 1995, 1, 1 ), 0 ],
[ "Fred", CreateDate( 1960, 1, 1 ), 0 ],
[ "Jim" , CreateDate( 1988, 1, 1 ), 0 ]
]);
Dump( var=people, label="people - origional query" );
@ivanionut
ivanionut / ExampleQuery.cfm
Created June 3, 2018 16:24 — forked from mpadmore/ExampleQuery.cfm
Example of queryExecute
<cfscript>
people = queryNew(
"id, firstName, lastName, email, country, ip_address",
"integer, varchar, varchar, varchar, varchar, varchar",
[{
"id": 1,
"firstName": "Christopher",
"lastName": "Burton",
"email": "cburton0@disqus.com",
"country": "Poland",
component output="false" displayname="SimplePGP" {
public SimplePGP function init(Required String config="PDS") {
variables.logger = application.logbox.getLogger(this);
switch(arguments.config) {
default: {
variables.publicKeyPath = expandPath('/path/to/key.pub');
@ivanionut
ivanionut / nova_sds011.py
Created November 19, 2017 18:10 — forked from marw/nova_sds011.py
Get reading from Nova PM Sensor SDS011 (dust sensor, air quality sensor, PM10, PM2,5) with sleep option
import time
import logging
try:
import serial
except ImportError:
print('Python serial library required, on Ubuntu/Debian: ' +
'apt-get install python-serial python3-serial')
raise
<!--- https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/package-summary.html --->
<cfset oCSV = createobject( "java", "org.apache.commons.csv.CSVFormat" )>
<cfset oParserObj = createobject( "java", "org.apache.commons.csv.CSVParser" )>
<cfdump var="#oParserObj#" expand="false">
<cfset oIOFile = createobject( "java", "java.io.File" ).init( expandpath( "./CLIENTIMPORT.csv" ) )>
<cfset oCharset = createobject( "java", "java.nio.charset.StandardCharsets" )>
<cfset oFormat = oCSV.EXCEL.withDelimiter( "|").withFirstRecordAsHeader().withQuote(javacast("char","")).withRecordSeparator("\r\n")>
<cfdump var="#oIOFile#" expand="false">