Skip to content

Instantly share code, notes, and snippets.

View lotharthesavior's full-sized avatar

Sávio Resende lotharthesavior

View GitHub Profile
@lotharthesavior
lotharthesavior / gist:0f9c33175caad0052d79
Last active January 8, 2016 21:09 — forked from yurydelendik/gist:f2b846dae7cb29c86d23
Hightlight Selected Text in PDFJS
function HighlightSelectedText()
{
var pageIndex = window.PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = window.PDFViewerApplication.pdfViewer.pages[pageIndex];
var pageElement = page.canvas.parentElement;
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var i = 0;
@lotharthesavior
lotharthesavior / .bash_profile
Created February 26, 2019 10:35
Docker Formatting at bash profile variable
# Docker ps format
export FORMAT="\nID\t{{.ID}}\nIMAGE\t{{.Image}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.RunningFor}}\ nSTATUS\t{{.Status}}\nPORTS\t{{.Ports}}\nNAMES\t{{.Names}}\n"
export IMG_FORMAT="\nREPOSITORY\t{{.Repository}}\nTAG\t{{.Tag}}\nID\t{{.ID}}\nCREATEDAT\t{{.Creat edAt}}\nSIZE\t{{.Size}}\n"
export DM_FORMAT="\nNAME\t{{.Name}}\nACTIVE\t{{.Active}}\nDRIVER\t{{.Driver}}\nSTATE\t{{.State}}\ nURL\t{{.Url}}\nSWARM\t{{.Swarm}}\nDOCKER\t{{.Docker}}\nERRORS\t{{.Errors}}\n"
@lotharthesavior
lotharthesavior / xrandr-scale.sh
Created March 25, 2019 20:36 — forked from 3v1n0/xrandr-scale.sh
Xrandr Scaling script, with auto panning when scaling down
#!/bin/bash
export LANG=C
output=$1;
scale=$2;
if [ -n "$output" ] && ! (xrandr --listmonitors | grep -qw "$output"); then
echo "Invalid output: '$output'";
exit 1;
@lotharthesavior
lotharthesavior / typora.desktop
Created March 29, 2019 21:46
File to register app on linux menu - to be placed at "/usr/share/applications "
[Desktop Entry]
Encoding=UTF-8
Exec=/home/savio/Documents/applications/Typora-linux-x64/Typora
Icon=/home/savio/Documents/applications/Typora-linux-x64/favicon-64.png
Type=Application
Terminal=false
Comment=Typora Markdown Editor
Name=Typora
GenericName=typora
StartupNotify=false
<?php
namespace App\Library\Services;
use Facades\Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
class CustomFileLog
@lotharthesavior
lotharthesavior / Docker_remove_containers_images.sh
Last active March 29, 2020 13:09
Clear Docker images and containers
# containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# images
docker rmi $(docker images -a -q)
@lotharthesavior
lotharthesavior / diffstring.sh
Created April 30, 2020 18:20
Diff 2 strings with Git Diff
#!/bin/bash
git diff $(echo $1 | git hash-object -w --stdin) $(echo $2 | git hash-object -w --stdin) --color-words=.
@lotharthesavior
lotharthesavior / block.js
Last active September 14, 2020 02:23
Gutenberg Base Block
var wpddb = {}
wpddb.contentTag = 'p';
wpddb.contentClass = 'wpddb-content';
(function (blocks, editor, element) {
var el = wp.element.createElement;
var RichText = editor.RichText;
blocks.registerBlockType('wpddb/promotion', {
title: 'WPDDB Promotion',
@lotharthesavior
lotharthesavior / wp-show-registered-filters.php
Last active March 25, 2021 17:28
WordPress - show registered filters for hooks
<?php
function show_registered_filters( $hook = '' ) {
global $wp_filter;
if( empty( $hook ) || !isset( $wp_filter[$hook] ) )
return;
echo '<pre>';
@lotharthesavior
lotharthesavior / Autoloader.php
Created May 21, 2021 05:58 — forked from Nilpo/Autoloader.php
A simple recursive PHP autoloader using the RecursiveDirectoryIterator.
<?php
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Rob Dunham
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights