Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile

Smettere di credere a chi vi dice che si può diventare bravi programmatori in sei mesi.

Smettere di credere ad ogni post su linkedin.

  1. Generate the file:
$ awk 'BEGIN { for(c=0;c<10000000;c++) printf "<p>LOL</p>" }' > 100M.html
$ (for I in `seq 1 100`; do cat 100M.html; done) | pv | gzip -9 > 10G.boomgz
  1. Check it is indeed good:
@JamoCA
JamoCA / coldfusion-thread-count.cfm
Last active July 31, 2021 12:46
ColdFusion utility UDFs to identify running threads; returns count or array of script files. #cfml
<cfscript>
numeric function getActiveThreadCount() hint="I return quantity of active requests (not including cf-threads)" {
local.threadCount = javacast("int", 0);
local.thread = createobject("java","java.lang.Thread");
local.stackTrace = local.thread.getAllStackTraces();
local.stackArray = local.stackTrace.entrySet().toArray();
for (local.stackIndex=1; local.stackIndex < arrayLen(local.stackArray); local.stackIndex+=1){
try{
local.thisThread = local.stackArray[local.stackIndex].getValue();
for (local.threadIndex=1; local.threadIndex < arrayLen(local.thisThread); local.threadIndex+=1){
@JamoCA
JamoCA / arrayFirstDefined.cfm
Last active March 1, 2021 21:02
ArrayFirstDefined: Returns first "defined" array item (ColdFusion cfml)
<cfscript>
/* 20210301 ArrayFirstDefined: Returns first "defined" array item
TryCF: https://www.trycf.com/gist/9bac4917179a3e44a542bc4768a95a31
Twitter: https://twitter.com/gamesover/status/1366439036903120897
ACF: Requires CF2018+ to use arrayFirst().
Lucee CFML: Reproted arrayFirst() bug. https://luceeserver.atlassian.net/browse/LDEV-3319 */
any function arrayFirstDefined(required array array, any fallbackValue="") output=false hint="Returns first defined array item" {
for (local.item in arguments.array){
if (not isNull(local.item)) return local.item;
}
@JamoCA
JamoCA / isFlushed.cfm
Last active January 21, 2021 22:17
ColdFusion / CFML UDF to determine if request/content has been flushed using CFFlush or by exceeding max buffer.
<cfscript>
/* 20200121 ColdFusion / CFML UDF to determine if request/content has been flushed using CFFlush or by exceeding max buffer. */
boolean function isFlushed(){
var response = false;
var headers = {};
if (StructKeyExists(request, "isFlushedAlready") AND isValid("boolean", request.isFlushedAlready) and request.isFlushedAlready){
return true;
}
headers = GetHttpRequestData(false).headers;
if (StructKeyExists(headers, "Expect") or not len(CGI.HTTP_Connection)){
@bennadel
bennadel / RedisGateway.cfc
Created November 7, 2020 14:25
Using Redis Blocking List Operations To Power Long-Polling In Lucee CFML 5.3.7.47
component
output = false
hint = "I provide a super simple wrapper around getting and returning Redis resources."
{
/**
* I initialize the Redis resource wrapper using Jedis 3.3.0.
*/
public void function init() {
@JamoCA
JamoCA / getTemplatesUsed.cfm
Last active October 27, 2020 17:28
Returns a query with execution stack containing line, parent, template, function and totaltime. (ColdFusion) Requires debugging to be enabled.
<cfscript>
/* 10/26/2020 Returns a query with execution stack containing line, parent, template, function and totaltime.
Requires debugging to be enabled. If debugging is not enabled, an empty query is returned
Inspired by combination of scripts here https://www.bennadel.com/blog/116-finding-template-execution-stack-in-coldfusion.htm
If desired, replace encrypted "WEB-INF/debug/classic.cfm" template with empty script (or edit from https://github.com/joshknutson/coldfusion-debug ) */
query function getTemplatesUsed() output="false" hint="Returns query with execution stack: line, parent, template, function and totaltime." {
var temp = {r=0, re = "\|(.*?)(\(|\])" };
var objFactory = CreateObject("java", "coldfusion.server.ServiceFactory");
var st = CreateObject("java", "java.lang.String");
var objDebugging = objFactory.GetDebuggingService();
@mmstick
mmstick / xanmod-install.sh
Last active October 4, 2023 18:43
Script for installing xanmod on Pop!_OS
#!/bin/bash
set -e
for field in $(cat /proc/cmdline); do
if [[ "${field}" = root=* ]]; then
UUID=$(echo $field | awk -F= '{print $3}')
break
fi
done
@rufoa
rufoa / patch.sh
Last active October 11, 2024 03:41
sublime merge 2 build 2068 linux
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
target="${1:-/opt/sublime_merge/sublime_merge}"
check_sha() {
local sha_valid
@jfcherng
jfcherng / st4-changelog.md
Last active August 18, 2024 07:25
Sublime Text 4 changelog just because it's not on the official website yet.