Skip to content

Instantly share code, notes, and snippets.

View gsdefender's full-sized avatar
💭
I may be slow to respond.

Emanuele Cipolla gsdefender

💭
I may be slow to respond.
View GitHub Profile
@pauliusef
pauliusef / gist:c7bcc96481fb3113cc78ae1246901e6f
Created August 15, 2017 09:16
Select every second line in Sublime
Search for : (.*(\n|$)){2}
alt+R - to toggle regular expression search
alt+ENTER - to select all results
@alepez
alepez / fix.md
Created November 25, 2016 13:59
Ubuntu 16.04 (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)
sudo apt-get install xserver-xorg-legacy

Edit /etc/X11/Xwrapper.config

allowed_users=anybody
needs_root_rights=yes
@alexcorvi
alexcorvi / mime2ext.php
Created June 29, 2016 10:04
converting mime types to extension in php
function mime2ext($mime){
$all_mimes = '{"png":["image\/png","image\/x-png"],"bmp":["image\/bmp","image\/x-bmp","image\/x-bitmap","image\/x-xbitmap","image\/x-win-bitmap","image\/x-windows-bmp","image\/ms-bmp","image\/x-ms-bmp","application\/bmp","application\/x-bmp","application\/x-win-bitmap"],"gif":["image\/gif"],"jpeg":["image\/jpeg","image\/pjpeg"],"xspf":["application\/xspf+xml"],"vlc":["application\/videolan"],"wmv":["video\/x-ms-wmv","video\/x-ms-asf"],"au":["audio\/x-au"],"ac3":["audio\/ac3"],"flac":["audio\/x-flac"],"ogg":["audio\/ogg","video\/ogg","application\/ogg"],"kmz":["application\/vnd.google-earth.kmz"],"kml":["application\/vnd.google-earth.kml+xml"],"rtx":["text\/richtext"],"rtf":["text\/rtf"],"jar":["application\/java-archive","application\/x-java-application","application\/x-jar"],"zip":["application\/x-zip","application\/zip","application\/x-zip-compressed","application\/s-compressed","multipart\/x-zip"],"7zip":["application\/x-compressed"],"xml":["application\/xml","text\/xml"],"svg":
@ddemuth
ddemuth / woocommerce-custom-email-recipient.php
Last active January 30, 2021 21:42
Customize the email recipient
//WooCommerce Email Customizations
add_filter( 'woocommerce_email_recipient_customer_note', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_completed_order', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_invoice', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_processing_order', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
/**
* $recipient could be comma separated to send to additional people
* EX. $recipient .= ', $additonal_recipient';
*/
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*

Reverse proxy over 3G modem (draft)

We will explain how to configure a cubieboard running debian as a reverese proxy. The modules that will be used are wvdial and autossh

Credits goes to:

1. http://blog.rootshell.be/2015/02/19/my-little-pwnie-box/
2. https://wiki.archlinux.org/index.php/3G_and_GPRS_modems_with_pppd
@styxyang
styxyang / numlock_osx.xml
Last active July 26, 2022 03:36
This is a Karabiner configuration to get NumLock work on OS X the same way as PC
<!-- Get NumLock on keypad to work on osx for G80-3494, Realforce and so on -->
<!-- By https://groups.google.com/d/msg/osx-karabiner/-2ns5XVXXdQ/kDGIKVSztjwJ -->
<item>
<name>Map NumLock to OSX NumLock function</name>
<identifier>private.pc_numlock_to_mac_numlock</identifier>
<autogen>__KeyToKey__ KeyCode::KEYPAD_CLEAR, KeyCode::VK_IOHIKEYBOARD_TOGGLE_NUMLOCK</autogen>
</item>
#!/bin/bash
# credits to: https://gist.github.com/2called-chaos/4285767
# Install:
# curl -O https://gist.githubusercontent.com/ziogaschr/74884b8d5095c86a7cef/raw/d236c87d89a34b588f37838843279e8e02f073e9/setup-autossh-tunnel.sh
# chmod u+x setup-autossh-tunnel.sh
# ./setup-autossh-tunnel.sh
#
# Extra:
# it is good to make a new user on both host and remote (http://linuxaria.com/howto/permanent-ssh-tunnels-with-autossh)
# useradd -m -s /bin/false autossh
@kgundula
kgundula / boundbox
Last active September 22, 2016 15:43
Calculate distance between two sets lat/lon coordinates and Calculate destination lat/lon given a starting point lat/lon cordinates, bearing, and distance, and Calculate the bounding box
// Calculating the bounding box
function boundbox ($lat, $lon, $distance, $units="km") {
return array ( "N" => getDestinationCoordinates ($lat,$lon, 0,$distance,$units),
"E" => getDestinationCoordinates ($lat,$lon, 90,$distance,$units),
"S" => getDestinationCoordinates ($lat,$lon, 180,$distance,$units),
"W" => getDestinationCoordinates ($lat,$lon, 270,$distance,$units));
}
@ichord
ichord / gist:9808444
Created March 27, 2014 14:12
demo of using pdf.js to extract pages to images
<script src="http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script><html>
<!--
Created using jsbin.com
Source can be edited via http://jsbin.com/pdfjs-helloworld-v2/8598/edit
-->
<body>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
<input id='pdf' type='file'/>
<!-- Use latest PDF.js build from Github -->