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 / nova_sensor.py
Created November 13, 2017 15:58 — forked from netmaniac/nova_sensor.py
Nova SDS011 sensor. Code is free to use in own projects, but I don't provide any support nor don't make me liable if it is not working :)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import serial, time, struct, array
from datetime import datetime
ser = serial.Serial()
ser.port = "/dev/ttyUSB0" # Set this to your serial port
ser.baudrate = 9600
@ivanionut
ivanionut / sds011.py
Created October 23, 2017 09:23 — forked from jon1012/sds011.py
Read an SDS011 Laser PM2.5 Sensor (Nova PM Sensor) with Python
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import serial, time, struct
import httplib, urllib
ser = serial.Serial("/dev/ttyUSB0", baudrate=9600, stopbits=1, parity="N", timeout=2)
ser.flushInput()
@ivanionut
ivanionut / sds011.py
Created October 23, 2017 09:21 — forked from geoffwatts/sds011.py
Read an SDS011 Laser PM2.5 Sensor (Nova PM Sensor) with Python
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import serial, time, struct
ser = serial.Serial()
ser.port = "/dev/cu.wchusbserial1410" # Set this to your serial port
ser.baudrate = 9600
ser.open()
@ivanionut
ivanionut / isEmailDomainValid.cfm
Created September 7, 2017 08:21 — forked from JamoCA/isEmailDomainValid.cfm
ColdFusion UDF to validate if an email address' MX record exists. (Spammers tend to generate random domain strings when submitting comment spam.)
<!--- NOTE: This technique is not 100% accurate because some DNS servers don't allow MX queries or may be slow to respond,
but this will identify addresses that are potentially bad or suspicious. --->
<cfscript>
function isEmailDomainValid(email){
var local.email = arguments.email;
var local.DNSServer = '8.8.8.8'; /* Google DNS */
var local.timeout = 2000;
var local.attempts = 1;
var local.valid = true;
var local.emailDomain = trim(listlast(local.email,'@'));
@ivanionut
ivanionut / nginx-pagespeed.conf
Created June 26, 2017 20:22 — forked from rahul286/nginx-pagespeed.conf
nginx + pagespeed downstream caching example
#source: http://www.jefftk.com/2014-01-03--nginx.conf
# for debugging with valgrind
#daemon off;
#master_process off;
#user nobody;
worker_processes 1;
worker_rlimit_core 500M;
<cfscript>
cfhttp(url="https://www.guidaworld.it/come-creare-una-intro-video-figa-con-sony-vegas-pro/" method="head" result="verificaStatusCodeURL" timeout="15" resolveurl="yes" redirect="yes" ) {
cfhttpparam (type="header" name="Accept-Encoding" value="*");
cfhttpparam (type="header" name="TE" value="deflate;q=0");
}
dump(verificaStatusCodeURL);
</cfscript>
@ivanionut
ivanionut / ga_proxy.conf
Created May 18, 2017 20:03 — forked from 0xDing/ga_proxy.conf
Google Analytics Proxy
server {
listen 443 http2 ssl;
server_name analytics.example.com;
location /ga_proxy {
proxy_set_header X-real-ip $remote_addr;
rewrite ^/ga_proxy/(.*)$ /$1?$args&uip=$remote_addr;
proxy_pass http://www.google-analytics.com;
break;
}
location /analytics.js {
@ivanionut
ivanionut / Application.cfc
Created March 8, 2017 22:40 — forked from roryl/Application.cfc
Sample Lucee Application.cfc
component {
// The application name. If you do not set this variable, or set it to the empty string, your CFC applies to the unnamed application scope, which is the Lucee J2EE servlet context. THIS.name = "foo";
this.name = "foo";
/*
this.applicationTimeout = createTimeSpan(0, 1, 0, 0); // Life span, as a real number of days, of the application, including all Application scope variables.
this.clientManagement = false; // Whether the application supports Client scope variables.
this.clientStorage = "registry"; //cookie||registry||datasource // Where Client variables are stored; can be cookie, registry, or the name of a data source. this.customTagPaths = ""; // Contains Lucee custom tag paths. this.datasource = ""; // Name of the data source from which the query retrieves data.

By now you've learned the basics of ColdFusion, script vs. tag syntax, scopes, how to deal with data, and even some code-reuse techniques. You're now able to write something useful, so it's time we introduce you to the Request Lifecycle.

You see, when someone requests a ColdFusion page, CF doesn't just start executing your code. There are several events that first take place, which you can be waiting for, and to which you can react. This is not strictly necessary, but you'll find that any complex application will eventually want to make use of some or all of these features, so it's best that you know about them. In order to react to these events, you need to have an Application.cfc file. ColdFusion has designated Application.cfc as a special component that it will automatically look for, and in which we can put our event listeners for request lifecycle events.

A Note on Terminolog
@ivanionut
ivanionut / lucee.cfm
Created March 7, 2017 21:06
bug lucee?
<cfscript>
public any function test(
required numeric id
, required text hint="lorem ipsum"
) {
return true;
}
writedump(test(1,"2"));
</cfscript>