Skip to content

Instantly share code, notes, and snippets.

View reatlat's full-sized avatar
🍋
Life gave me lemons, I forked.

Alex Zappa reatlat

🍋
Life gave me lemons, I forked.
View GitHub Profile
@reatlat
reatlat / get-browser-language.php
Created June 17, 2018 08:05 — forked from LucaRosaldi/get-browser-language-code.php
PHP: Detect Browser Language
<?php
/**
* Get browser language, given an array of avalaible languages.
*
* @param [array] $availableLanguages Avalaible languages for the site
* @param [string] $default Default language for the site
* @return [string] Language code/prefix
*/
function get_browser_language( $available = [], $default = 'en' ) {
if ( isset( $_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ] ) ) {
@reatlat
reatlat / .serverstatus.sh
Created June 18, 2018 22:13 — forked from seyDoggy/.serverstatus.sh
Shell script to monitor HTTP server status and email me when the server is not responding.
#!/bin/bash
NAME=Adam
TESTDATE=`date "+%B %e, %Y"`
TESTTIME=`date "+%H:%M:%S"`
auto_init() {
runTest
}
runTest() {

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@reatlat
reatlat / gist:d81eb8e9cd2f86b46eed778924132f3c
Created September 5, 2018 21:54 — forked from nkint/gist:8563954
ffmpeg in the shell: extracting the first frame of video
i=1
for avi in *.mp4; do
name=`echo $avi | cut -f1 -d'.'`
jpg_ext='.jpg'
echo "$i": extracting the first frame of the video "$avi" into "$name$jpg_ext"
ffmpeg -loglevel panic -i $avi -vframes 1 -f image2 "$name$jpg_ext"
i=$((i+1))
done
@reatlat
reatlat / clean_wordpress_head.php
Created September 25, 2018 18:32 — forked from robwent/clean_wordpress_head.php
A collection of snippets for a Wordpress theme's function.php file to clean up the output
<?php
/**
* Core output
**/
//Remove the generator tag
remove_action('wp_head', 'wp_generator');
//Remove the frontend admin bar while in development
@reatlat
reatlat / mailcheck.php
Created September 25, 2018 18:32 — forked from robwent/mailcheck.php
Drop in a folder and browse to it to check php mail is working.
<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Email successfully sent!</p>");
} else {
echo("<p>Email delivery failed!</p>");
}
?>
@reatlat
reatlat / webstoemp-gulpfile.js
Created November 11, 2018 22:11 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@reatlat
reatlat / nyan-cat-console.js
Created March 17, 2019 03:09 — forked from rdlh/nyan-cat-console.js
Get the NYAN CAT in your developer console !
var _nyan = 0;
var __nyan = [[
"+ o + o ",
" + o + + ",
"o + ",
" o + + + ",
"+ o o + o ",
"-_-_-_-_-_-_-_,------, o ",
"_-_-_-_-_-_-_-| /\\_/\\ ",
"-_-_-_-_-_-_-~|__( ^ .^) + + ",
<script type="text/javascript">
// Original idea taken here
// @link https://community.unbounce.com/t/require-business-email-address/14158
(function () {
// set interval to check if jQuery loaded
var int_jQuery = setInterval(function () {
// add additional metood for check free emails
if (typeof lp.jQuery === "function") {
// clear interval for jQuery becoase lp.jQuery already loaded
clearInterval(int_jQuery);
@reatlat
reatlat / jquery.donetyping.js
Created April 7, 2019 01:22
Jquery custom event handler , triggers when user stop typing.
/*
* $('#element').donetyping(callback[, timeout=1000])
*
* source: http://stackoverflow.com/a/14042239/3705299
*
* Fires callback when a user has finished typing. This is determined by the time elapsed
* @callback: function to be called when even triggers
* @timeout: (default=1000) timeout, in ms, to to wait before triggering event if not caused by blur.
* Requires jQuery 1.7+
* Tested with jQuery 1.11.3