Skip to content

Instantly share code, notes, and snippets.

View duzun's full-sized avatar
🎯
Focusing

Dumitru Uzun duzun

🎯
Focusing
View GitHub Profile
@duzun
duzun / undetect-console.js
Created March 20, 2020 12:41
Try to make console undetectable (and broken)
console.log =
console.clear =
console.profile =
console.profileEnd =
eval = function(){};
@duzun
duzun / isUTF8.php
Last active March 13, 2020 15:59
Check whether a string can be interpreted as a valid UTF-8 or if it has any non-ASCII UTF-8 bytes
<?php
/**
* Check whether string $str can be interpreted as a valid UTF-8.
*
* @param (string) $str A string to check for UTF-8
* @param (bool) $hasNonASCII_UTF8 If true, get non-ASCII bytes count in $str.
*
* @return (bool|int) if $str is not a valid UTF-8 string -> false
* if $str is a valid UTF-8 string,
* when $hasNonASCII_UTF8 == false -> true,
@duzun
duzun / casign
Created February 24, 2020 14:23
Create a SSL certificate signed by your CA root certificate.
#!/usr/bin/env bash
##
# Sign a certificate using my root_ca.
#
# Note: duzun_root_ca.crt must be in the trusted root ca (see https://www.archlinux.org/news/ca-certificates-update/)
#
# @author Dumitru Uzun (DUzun.Me)
# @version 1.1.0
##
@duzun
duzun / url.js
Last active February 7, 2020 11:22
In Browser URL parser
/**
* Parse URLs in a Browser environment.
*
* Ussage:
* 1) var hostname = $url('https://duzun.me/playground', 'hostname');
*
* 2) var a = $url('https://duzun.me/playground?some=param');
* a.protocol = 'http:';
* var hrefSecured = a.href;
*/
@duzun
duzun / jq.fn.counto.js
Created November 12, 2014 09:11
Nice count to number
/// Nice count to number (by DUzun)
;(function (global, FUNCTION, Number) {
var $ = global.jQuery || global.Zepto;
$.fn.counto = function fcounto(nr,dl,done) {
if(!dl) dl = 400;
var start = $.now(),
end = start + dl,
delay = 10,
@duzun
duzun / downlist
Last active February 7, 2020 10:59
Download media files from a m3u8 URL
#!/bin/bash
# Download a file listed in a list file
# @author Dumitru Uzun (DUzun.Me)
# @version 1.0.1
_me_="$(basename "$0")"
_start_time_=$(date +%s)
referer=
_cat_=
@duzun
duzun / shiftsrt.js
Last active February 7, 2020 10:59
Shift time in .srt subtitles file
#!/bin/node
/*jshint esversion: 9*/
/**
* Time-shift video subtitles in a .srt file.
*
* Usage:
* shiftsrt.js seconds input_file|- [output_file|-]
*
* Examples:
@duzun
duzun / php_sess_to_redis.sh
Last active July 4, 2019 10:36
Bash script to import PHP session files into redis
#!/bin/bash
export REDISCLI_AUTH=my-supper-strong-password-4-redis-server
TTL=$(( 24 * 3600 ))
# cd "/var/sess"
for i in sess_*; do
ex=$(( $(date +%s) - $(stat -c %Y "$i") + $TTL ))
@duzun
duzun / fix_lib_links.sh
Created December 25, 2018 23:04
Fix /usr/lib/lib*.so links, in the case you `cp`ed lib folder from a backup (use `rsync -a`, not `cp`!)
@duzun
duzun / optimag
Last active August 11, 2018 00:54
Compresses images using on-line services.
#!/bin/sh
# https://gist.github.com/duzun/234bd3ca69b243bb32bb
basedir=`dirname "$0"`
optimagurl=https://duzun.me/optimag.js
optimagjs=$basedir/optimag.js
case `uname` in
*CYGWIN*) optimagjs=`cygpath -w "$optimagjs"`;;