Skip to content

Instantly share code, notes, and snippets.

@leonelsr
leonelsr / ideize.js
Created May 21, 2012 23:46
String prototype that transforms any string into a "ID" usable string by replacing portuguese special characters into their simple equivalents and stripping all remaining special chars.
/* Transforms any string into a "ID" usable string by replacing portuguese special characters into their simple equivalents and stripping all remaining special chars. */
String.prototype.IDize = function () {
var texto = this;
var chrEspeciais = new Array("\u00e1", "\u00e0", "\u00e2", "\u00e3", "\u00e4", "\u00e9", "\u00e8", "\u00ea", "\u00eb", "\u00ed", "\u00ec", "\u00ee", "\u00ef", "\u00f3", "\u00f2", "\u00f4", "\u00f5", "\u00f6", "\u00fa", "\u00f9", "\u00fb", "\u00fc", "\u00e7", "\u00c1", "\u00c0", "\u00c2", "\u00c3", "\u00c4", "\u00c9", "\u00c8", "\u00ca", "\u00cb", "\u00cd", "\u00cc", "\u00ce", "\u00cf", "\u00d3", "\u00d2", "\u00d4", "\u00d5", "\u00d6", "\u00da", "\u00d9", "\u00db", "\u00dc", "\u00c7");
var chrNormais = new Array("a", "a", "a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "u", "u", "u", "u", "c", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "I", "I", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C");
for(index in chrEspeciais) {
texto = texto

Keybase proof

I hereby claim:

  • I am leonelsr on github.
  • I am leonelsr (https://keybase.io/leonelsr) on keybase.
  • I have a public key ASAU8GXH2lcMuHHWLVNfvXym7VfTPeiPMQ344hgNSx1hGgo

To claim this, I am signing this object:

/* Use 100% CPU on multithreaded Windows systems */
#include <Windows.h>
#include <stdio.h>
#define NUM_THREADS 4
DWORD WINAPI mythread(__in LPVOID lpParameter)
{
printf("Thread inside %d \n", GetCurrentThreadId());
@leonelsr
leonelsr / test-php-basic-auth.php
Created January 11, 2019 22:33 — forked from rchrd2/test-php-basic-auth.php
PHP basic auth example
<?php
function require_auth() {
$AUTH_USER = 'admin';
$AUTH_PASS = 'admin';
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
@leonelsr
leonelsr / DESPERTADOR.cmd
Last active April 6, 2019 02:36
Despertador com windows batch e task scheduler
@echo off
SETLOCAL
SET mpchc="C:\Program Files\MPC-HC\mpc-hc64.exe"
SET imperial="C:\Users\Leonel\Music\John Williams\The Greatest Hits_ 1969-1999 Disc 1\10 'The Imperial March' from The Emp.m4a"
SET dontlie="C:\Users\Leonel\Music\The Black Eyed Peas\Monkey Business\04 Don't Lie.m4a"
SET hedwig="C:\Users\Leonel\Music\John Williams\Harry Potter And The Philosopher's Stone\19 Hedwig's Theme.m4a"
SET starwars="C:\Users\Leonel\Music\John Williams\The Greatest Hits_ 1969-1999 Disc 1\01 Star Wars (Main Title) [From Star.m4a"
@leonelsr
leonelsr / OldTwitterAvatar.user.js
Last active April 6, 2019 22:43
Twitter and Tweetdeck #OldTwitter Avatar
// ==UserScript==
// @name Twitter and Tweetdeck #OldTwitter Avatar
// @namespace http://tampermonkey.net/
// @version 0.1.2
// @downloadURL https://gist.githubusercontent.com/leonelsr/b105375be316540dbcc7e76dabcd02c6/raw/OldTwitterAvatar.user.js
// @description Bring the old square Avatar back to Twitter and TweetDeck!
// @author @leonelsr
// @match https://tweetdeck.twitter.com/
// @match https://twitter.com/*
// @grant none
// ==UserScript==
// @name Globo Full Tab
// @namespace https://gist.github.com/leonelsr
// @version 0.1.3
// @downloadURL https://gist.github.com/leonelsr/095f42ff5904432d4532f27ce92b9b85/raw/GloboFullTab.user.js
// @description Cria um botão para deixar em Tela Cheia (ou "aba cheia") qualquer vídeo em Globo.com (inclusive G1, Globo Play ou Globosat Play).
// @author @leonelsr
// @match *://*.globo.com/*
// @grant none
// ==/UserScript==
<!DOCTYPE html><html lang="en"><head>
<title>SDDS CEVA | 30 do Hellboy</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@leonelsr
leonelsr / xmrigidle.ahk
Last active June 2, 2020 21:04
AutoHotkey XMRig controller tool - Dynamically changes XMRig settings when PC is idle for some time
#SingleInstance force ; Skips the dialog box and replaces the old instance automatically
#Persistent
SetWorkingDir %A_ScriptDir%
/*
* XMRig controller tool
*
* Can be used to dynamically change XMRig settings whenever PC is idle for some time
* At the bottom of this file, there is an example of config.json file for reference
@leonelsr
leonelsr / resize-class.php
Created August 8, 2012 04:01
PHP Image crop and Resize helper class
<?php
# ========================================================================#
#
# Author: Jarrod Oberto
# Version: 1.1
# Date: 08-Aug-12
# Purpose: Resizes and saves or shows image
# Requires : Requires PHP5, GD library.
# Usage Example: