Skip to content

Instantly share code, notes, and snippets.

@blood72
blood72 / RestrictFromReferer.php
Last active January 21, 2021 13:56
(Laravel) Allow request only if Referrer header is base same domain
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class RestrictFromReferer
{
@clintoncrick
clintoncrick / zwave-events.py
Created February 21, 2017 04:00
Script to monitor OpenZWave events for Remotec ZRC-90US and send event to Home Assistant. Supports single click, double click, and long press.
#!/usr/bin/env python3
import socket
import requests
from subprocess import Popen, PIPE
import json
# These lines are examples only. They may be useful to compare what your remote sends. To capture the codes that your remote sends,
# tail the OZW_Log.
@atomtigerzoo
atomtigerzoo / wordpress-disable-yoast-seo-on-custom-post-type.php
Created March 31, 2016 12:39
Wordpress: Disable Yoast SEO on Custom Post Type
function my_remove_wp_seo_meta_box() {
remove_meta_box('wpseo_meta', YOUR_POST_TYPE_NAME_HERE, 'normal');
}
add_action('add_meta_boxes', 'my_remove_wp_seo_meta_box', 100);
@gabrieljenik
gabrieljenik / jquery-bootstrap-datepicker.css
Created December 29, 2015 21:37 — forked from miwahall/jquery-bootstrap-datepicker.css
jQuery UI Datepicker Bootstrap 3 Style
.ui-datepicker {
background-color: #fff;
border: 1px solid #66AFE9;
border-radius: 4px;
box-shadow: 0 0 8px rgba(102,175,233,.6);
display: none;
margin-top: 4px;
padding: 10px;
width: 240px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
@igrr
igrr / ESP8266_K30_DHT.ino
Created December 25, 2015 12:56
ESP8266 + K-30 CO2 Sensor over UART + DHT22 temperature/humidity sensor + MQTT
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
DHT dht(D5, DHT22);
const char* ssid = "........";
const char* password = "........";
IPAddress mqttServer(192, 168, 1, 10);
@wkw
wkw / WordPress On-Demand Custom Image Sizes
Created August 7, 2014 16:18
Add this to your WordPress functions.php if you are using many custom image sizes (add_image_size(...)) to prevent the creation of all the sizes upon image upload. This will only generate a custom size the first time it is requested.
/* ======================================================================================
//! -- On Demand Image Sizing --
Experimental code for generating custom image sizes on demand.
http://wordpress.stackexchange.com/a/124790
From the author...
"When an image is then requested in a particular size,
which is not yet generated, it will be created only that once."
====================================================================================== */
@mircobabini
mircobabini / wc_get_product_by_sku.php
Created August 4, 2014 09:51
Woocommerce function: Get product by SKU (with WPML support)
<?php
function wc_get_product_by_sku($sku) {
global $wpdb;
if( defined( 'ICL_LANGUAGE_CODE' ) ){
$product_id = $wpdb->get_var($wpdb->prepare("SELECT pm.post_id FROM ".$wpdb->postmeta." AS pm LEFT JOIN ".$wpdb->prefix."icl_translations AS tr ON pm.post_id = tr.element_id WHERE pm.meta_key='_sku' AND pm.meta_value='%s' AND tr.language_code = '".ICL_LANGUAGE_CODE."'", $sku));
} else {
$product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku));
}
@kopiro
kopiro / route.php
Created July 28, 2014 14:53
Bootstrap + Laravel | Server Side validation
<?php
$validator = Validator::make(Input::all(),
[
'name' => 'required',
'city' => 'required',
'address' => 'required',
'country' => 'required',
'site' => 'required',
'phone' => 'required',
@miwahall
miwahall / jquery-bootstrap-datepicker.css
Created October 17, 2013 17:10
jQuery UI Datepicker Bootstrap 3 Style
.ui-datepicker {
background-color: #fff;
border: 1px solid #66AFE9;
border-radius: 4px;
box-shadow: 0 0 8px rgba(102,175,233,.6);
display: none;
margin-top: 4px;
padding: 10px;
width: 240px;
}
@Rarst
Rarst / readme.md
Last active December 24, 2015 22:09
Bolt on of whoops to WordPress, rough, proper plugin some time later