Skip to content

Instantly share code, notes, and snippets.

View arosemena's full-sized avatar
🤖

Roberto Arosemena Elizondo arosemena

🤖
View GitHub Profile
@arosemena
arosemena / CapsToEsc.ps1
Created June 18, 2021 01:41
Maps the Caps Lock key to Esc in windows, needs a restart after
$bytes = "00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00".Split(',') | % { "0x$_"};
$key = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $key -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$bytes);
@arosemena
arosemena / hashdir.sh
Created November 21, 2018 21:54
renames files in the directory to their sha1 checksums keeping the extension
#!/bin/bash
# Renames all the files in the current directory
# to their sha1 checksums keeping the extension
# it prints the list of the converted files at
# the end
# Requires the shasum command that comes with xcode
ls
@arosemena
arosemena / FixDates.php
Created August 23, 2018 15:22
HTTP Middleware for Laravel
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TransformsRequest;
class FixDates extends TransformsRequest
{
protected function transform($key, $value)
{
@arosemena
arosemena / ranpass.sh
Created October 22, 2015 17:48
Generates a random password in bash, can be passed a parameter for length of said password, defaults to 30 characters if no parameter or if parameter isn't a number
case $1 in
''|*[!0-9]*) n=30 ;;
*) n=$1 ;;
esac
</dev/urandom tr -cd 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$@!' | head -c$n
@arosemena
arosemena / installation.sh
Created May 23, 2015 16:01
CentOS 7.0 Installation script (nginx, php-fpm, redis, postgresql), mainly for laravel
#!/bin/bash
#================#
# For CentOS 7.0 #
#================#
######## CONFIG ##########
user="user"
router="index.php"
@arosemena
arosemena / gist:eb8bad788adcca4d86eb
Created October 7, 2014 20:30
Javascript convert price to integer
toIntPrice = (number)->
price = number.match /(\d+)(\.\d{1,2})?/
if price[2]
price[2] = price[2].replace /\./g, ''
console.log price
if price[2].length == 1 then price[2] += '0'
else price[2] = '00'
if price then price = price[1] + price[2] else price = 0
return price
@arosemena
arosemena / LangCheck.php
Last active August 29, 2015 14:02
Simple class to check a client language from the HTTP headers
<?php
class LangCheck
{
private $default;
private $available;
/**
* @param array $available An array containing the available locales
* @param string $default The default language in case none is found
@arosemena
arosemena / gist:8465114
Last active June 11, 2018 21:22
Installation script for CentOS 6.4 (nginx, php-fpm, redis, postgres)
#!/bin/bash
# to see a more detailed progress do:
# tail -f install.log
######## CONFIG ##########
router="index.php"
serverRoot="/server"
domain="example.org"