Skip to content

Instantly share code, notes, and snippets.

View googlebe's full-sized avatar

herblab googlebe

View GitHub Profile
@googlebe
googlebe / validate_url.sh
Created December 11, 2017 00:55 — forked from rbramwell/validate_url.sh
Validate URL using Bash cURL - Check if a resource exists at a URL
#!/bin/bash
# Simple function to check http response code before downloading a remote file
# Example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url () {
if [[ `curl -s --head "$1" | head -n 1 | grep "HTTP/[1-3].[0-9] [23].."` ]]; then echo "true"; fi
}
@googlebe
googlebe / download_podcast.sh
Created December 11, 2017 00:56 — forked from bluvertigo/download_podcast.sh
bash wget - check if file exists at url before downloading
#!/bin/bash
# simple function to check http response code before downloading a remote file
# example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url () {
if [[ `curl -s --head "$1" | head -n 1 | grep "HTTP/[1-3].[0-9] [23].."` ]]
then
# 0 = true
@googlebe
googlebe / validate.sh
Created December 11, 2017 00:57 — forked from hrwgc/validate.sh
bash wget - check if file exists at url before downloading
#!/bin/bash
# simple function to check http response code before downloading a remote file
# example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi
}
@googlebe
googlebe / protect.conf
Created January 1, 2018 13:13 — forked from VirtuBox/protect.conf
Nginx Configuration to block SQL Injection and similar attacks
location ~* "(eval\()" { deny all; }
location ~* "(127\.0\.0\.1)" { deny all; }
location ~* "([a-z0-9]{2000})" { deny all; }
location ~* "(javascript\:)(.*)(\;)" { deny all; }
location ~* "(base64_encode)(.*)(\()" { deny all; }
location ~* "(GLOBALS|REQUEST)(=|\[|%)" { deny all; }
location ~* "(<|%3C).*script.*(>|%3)" { deny all; }
location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" { deny all; }
location ~* "(boot\.ini|etc/passwd|self/environ)" { deny all; }
location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" { deny all; }
@googlebe
googlebe / WP-HTML-Compression
Created January 6, 2018 12:09 — forked from sethbergman/WP-HTML-Compression
Minify HTML for WordPress without a Plugin - Add to function.php
<?php
class WP_HTML_Compression
{
// Settings
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
// Variables
@googlebe
googlebe / ip.set.bat
Created February 22, 2018 06:56 — forked from moolex/ip.set.bat
Windows下自动设置IP的批处理脚本
@echo off
::需要设置的网络,一般为“本地连接”或者“无线网络连接”
set name="无线网络连接"
::请根据您的参数修改以下数据
::设置 IP地址
set ipaddress=18.1.16.169
::设置 子掩码
set mask=255.255.252.0
::设置 网关
set gateway=18.1.19.254
@googlebe
googlebe / change_dns.bat
Created February 22, 2018 07:00 — forked from maravedi/change_dns.bat
Batch Script to Change DNS Servers
@ECHO OFF
ipconfig /all | findstr "Servers" | findstr "xx.xx.xx.xx"
if %ERRORLEVEL% equ 0 (
rem echo Findstr FOUND xx.xx.xx.xx in the DNS list.
goto google
) else (
rem echo Findstr DID NOT find xx.xx.xx.xx in the DNS list.
goto local
)
@googlebe
googlebe / ks-custom-login.js
Created May 13, 2018 13:14 — forked from konradsroka/ks-custom-login.js
Add Placeholders To WordPress Login Form And Remove Labels
// ----------------------------------------------------
// Adding the placeholders in textfields of login form
// ----------------------------------------------------
jQuery(document).ready(function($) {
$('#loginform input[type="text"]').attr('placeholder', 'Username');
$('#loginform input[type="password"]').attr('placeholder', 'Password');
@googlebe
googlebe / acf-future-posts.php
Created December 23, 2018 13:46 — forked from aderaaij/acf-future-posts.php
Advanced Custom Fields datepicker: Show only events with a date of today or in the future. Extra comments from Pasnon @ ACF Forums: f you needed to, you could also play with the comparison date, which is the first array in meta_query, currently set to date("Y-m-d") which is today; if you were to make it date("Y-m-d", strtotime("-1 day")) you cou…
<?php
/*
* Display posts only from today and in the future:
* http://old.support.advancedcustomfields.com/discussion/6000/how-to-sort-posts-by-acf-date-and-display-only-future-posts
* by Pasnon
*/
$date_args = array(
'post_type' => 'events',
/**
* ACF Form: Prevent default form submit
*/
jQuery(document).on('submit', '.acf-form', function(e) {
e.preventDefault();
});
/**
* ACF Form: Init
*/