Skip to content

Instantly share code, notes, and snippets.

View raveren's full-sized avatar

Rokas Šleinius raveren

View GitHub Profile
@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
@raveren
raveren / transliterate.php
Last active June 9, 2018 18:21
replace non-ascii characters to their latin counterparts.
function replaceLink( $string, $separator = '-' )
{
$search = array(
'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ā', 'Ą', 'Ă', 'Ç', 'Ć', 'Č', 'Ĉ', 'Ċ', 'Ď', 'Đ', 'È', 'É', 'Ê', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ĝ', 'Ğ', 'Ġ',
'Ģ', 'Ĥ', 'Ħ', 'Ì', 'Í', 'Î', 'Ï', 'Ī', 'Ĩ', 'Ĭ', 'Į', 'İ', 'IJ', 'Ĵ', 'Ķ', 'Ľ', 'Ĺ', 'Ļ', 'Ŀ', 'Ł', 'Ñ', 'Ń', 'Ň', 'Ņ', 'Ŋ', 'Ò', 'Ó', 'Ô', 'Õ',
'Ö', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Œ', 'Ŕ', 'Ř', 'Ŗ', 'Ś', 'Ş', 'Ŝ', 'Ș', 'Š', 'Ť', 'Ţ', 'Ŧ', 'Ț', 'Ù', 'Ú', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ũ', 'Ų', 'Ŵ',
'Ŷ', 'Ÿ', 'Ý', 'Ź', 'Ż', 'Ž', 'à', 'á', 'â', 'ã', 'ä', 'ā', 'ą', 'ă', 'å', 'æ', 'ç', 'ć', 'č', 'ĉ', 'ċ', 'ď', 'đ', 'è', 'é', 'ê', 'ë', 'ē', 'ę',
'ě', 'ĕ', 'ė', 'ƒ', 'ĝ', 'ğ', 'ġ', 'ģ', 'ĥ', 'ħ', 'ì', 'í', 'î', 'ï', 'ī', 'ĩ', 'ĭ', 'į', 'ı', 'ij', 'ĵ', 'ķ', 'ĸ', 'ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'ñ',
'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ō', 'ő', 'ŏ', 'œ', 'ŕ', 'ř', 'ŗ', 'ś', 'š', 'ş', 'ť', 'ţ', 'ù', 'ú', 'û', 'ü', 'ū', 'ů',
'ű', 'ŭ', 'ũ', 'ų', 'ŵ', 'ÿ', 'ý', 'ŷ', 'ż', 'ź', 'ž', 'ß', 'ſ', 'Α',
@raveren
raveren / AIO.ahk
Last active April 26, 2024 12:29
My personal autohotkey configuration (used and updated for 10+ years!)
;
; ██╗███╗ ██╗██╗████████╗██╗ █████╗ ██╗ ██╗███████╗███████╗
; ██║████╗ ██║██║╚══██╔══╝██║██╔══██╗██║ ██║╚══███╔╝██╔════╝
; ██║██╔██╗ ██║██║ ██║ ██║███████║██║ ██║ ███╔╝ █████╗
; ██║██║╚██╗██║██║ ██║ ██║██╔══██║██║ ██║ ███╔╝ ██╔══╝
; ██║██║ ╚████║██║ ██║ ██║██║ ██║███████╗██║███████╗███████╗
; ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝╚══════╝╚══════╝
;
; https://gist.github.com/raveren/bac5196d2063665d2154/edit
;
@raveren
raveren / open_current_wallpaper_windows.vbs
Last active January 17, 2024 18:27
Open current wallpaper in windows8
Set Shell = CreateObject("WScript.Shell")
' change to TranscodedImageCache_001 for second monitor and so on
openWallpaper("HKCU\Control Panel\Desktop\TranscodedImageCache_000")
function openWallpaper(regKey)
arr = Shell.RegRead(regKey)
a=arr
fullPath = ""
consequtiveZeroes = 0
<?php
const ✓ = true;
const ✕ = false;
function ≠($left, $right) {
return $left != $right;
}
function ≅($left, $right) {
@raveren
raveren / valid_email.php
Last active August 29, 2015 14:14
validate email
<?php
class Valid
{
/**
* Check an email address for correct format.
*
* @link http://www.iamcal.com/publish/articles/php/parsing_email/
* @link http://www.w3.org/Protocols/rfc822/
*
@raveren
raveren / GitHubFlow-idiotproofer.user.js
Last active April 21, 2016 12:49
[userscript] GitHubFlow PR merge idiot-proofing
// ==UserScript==
// @name GitHubFlow PR merge idiot-proofing
// @namespace https://gist.github.com/raveren/f08ba2673a92c582692e1a233621762f
// @version 0.3
// @author raveren
// @description Confirmation before common mistakes when merging Pull Requests in github
// @match https://github.com/*/pull/*
// ==/UserScript==
(function() {
@raveren
raveren / GitHub-add-RubyMine-link.user.js
Last active July 15, 2016 12:02
Link File to InteliJ IDE From Github
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// DEFINITIONS //////////////////////////////////////////////
///////////////// YOU CAN CHANGE CODE AT THE BOTTOM ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
const display = [
1, 1, 1, 0, 1, 1, 1,
1, 1, 1, 0, 1, 1, 1,
1, 1,
1, 1, 1, 0, 1, 1, 1,
@raveren
raveren / show-all-aliexpress-orders.user.js
Last active October 1, 2020 12:42
Show all your orders on one page in Aliexpress
// ==UserScript==
// @name Aliexpress show all orders
// @namespace none
// @version 0.1
// @date 2019-12-11
// @description Add new option to the 'Display items per page:' dropdown
// @author raveren
// @match *.aliexpress.com/orderList.htm*
// @match *.aliexpress.com/order_list.htm*
// @icon https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico