Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
@iscott
iscott / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Last active November 14, 2024 10:54
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 6 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4, 5, or 6
@netmaniac
netmaniac / nova_sensor.py
Last active February 26, 2025 10:09
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
@stevereich
stevereich / application.cfc
Last active December 10, 2023 04:58
Commented Custom Application.cfc Template Boilerplate - Coldfusion
component output="false" {
/* **************************** APPLICATION VARIABLES **************************** */
// 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 ColdFusion J2EE servlet
// context.
THIS.name = "foo";
// Life span, as a real number of days, of the application, including all Application scope variables.
THIS.applicationTimeout = createTimeSpan(0, 1, 0, 0);
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
<link rel="canonical" href="./amp-form-sub.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility
@18thAvenue
18thAvenue / functions.cfm
Created December 9, 2016 16:33
CFWheels Bootstrap 4 Pagination Function (Tag Based)
<!---
Instructions: Place this function in functions.cfm
In your findall():
myquery=model("Mymodel").findAll(page=params.page, perPage=params.perpage,handle="myHandleName");
In your view template place this code for the pagination links:
#bs4Pagination(paginationHandle="myHandleName",activepage="#params.page#",params="Not Required(optional params)")#
You can see in function arguments other parameters you can pass in from the bs4Pagination() function. --->
@nathfy
nathfy / S3Wrapper.cfc
Last active October 27, 2016 07:19 — forked from christierney402/S3Wrapper.cfc
Amazon Web Services (AWS) S3 Wrapper for ColdFusion
/**
* Amazon S3 REST Wrapper
* Version Date: 2015-09-03
*
* Copyright 2015 CF Webtools | cfwebtools.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@mcnamee
mcnamee / bitbucket-pipelines.yml
Last active December 14, 2023 03:57
Bitbucket Pipelines - Deploy via FTP to shared hosting
# Installation ---
# 1. In Bitbucket, add FTP_USERNAME, FTP_PASSWORD and FTP_HOST as environment variables.
# 2. Commit this file (bitbucket-pipelines.yml) to your repo (in the repo root dir)
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initialize GitFTP)
#
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (see 'Installation' above) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:deploy-all)
<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]);
}
@mcmullengreg
mcmullengreg / ColdFusion-Git-Webhook.cfm
Last active December 5, 2022 21:02
Webhoook integration for ColdFusion. Downloads the Zip after a push event and moves the contents to a folder determined based on the repository name. Used as a means of keeping testing environments updated whenever new commits are pushed to the master.
<!--- Webhook secrets -- yours, not mine. --->
<cfset secret = "">
<cftry>
<cfset _payload = "{}">
<cfset _payload = getHttpRequestData()>
<cfset jsonPayload = form.payload>
<cfset hash = RemoveChars(_payload.headers['X-Hub-Signature'], 1, 5)>
<cfset payload_hash = hmac(_payload.content, secret, 'HMACSHA1')>
@jon1012
jon1012 / sds011.py
Last active October 23, 2017 09:23 — 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
import httplib, urllib
ser = serial.Serial("/dev/ttyUSB0", baudrate=9600, stopbits=1, parity="N", timeout=2)
ser.flushInput()