Skip to content

Instantly share code, notes, and snippets.

View jeffreyvr's full-sized avatar
🎸
Freelancing and building my own stuff.

Jeffrey van Rossum jeffreyvr

🎸
Freelancing and building my own stuff.
View GitHub Profile
@jeffreyvr
jeffreyvr / .phpcs.xml.dist
Last active May 11, 2020 11:12
WordPress Theme or Plugin setup VSCode
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<!-- How to scan -->
@jeffreyvr
jeffreyvr / settings.json
Created February 1, 2020 15:35
VSC settings
{
"workbench.startupEditor": "none",
"markdown.preview.fontSize": 12,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"editor.fontSize": 16,
"editor.lineHeight": 42,
"workbench.colorCustomizations": {
"[Inspired Github]": {
"editorLineNumber.foreground": "#999",
@jeffreyvr
jeffreyvr / settings.json
Created November 9, 2019 20:58
VSC settings
{
"workbench.startupEditor": "none",
"markdown.preview.fontSize": 12,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"editor.fontSize": 16,
"editor.lineHeight": 42,
"workbench.colorCustomizations": {
"[Inspired Github]": {
"editorLineNumber.foreground": "#999",
@jeffreyvr
jeffreyvr / AuthServiceProvider.php
Last active December 2, 2020 20:22
Lumen Policies
<?php
namespace App\Providers;
use App\Post as Post;
use App\Policies\PostPolicy as PostPolicy;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
@jeffreyvr
jeffreyvr / whitelist.php
Created December 3, 2018 15:50
Generate commands to whitelist Cloudflare IP's (iptables)
<?php
$ips = file_get_contents( 'https://www.cloudflare.com/ips-v4' );
$ips = explode( PHP_EOL, $ips );
$result = '';
foreach ( $ips as $ip ){
@jeffreyvr
jeffreyvr / functions.php
Created October 23, 2018 10:25
Adding oEmbed filter in custom WordPress function
<?php
function prefix_get_custom_sidebar() {
global $post, $wp_embed;
$custom_sidebar = get_post_meta( $post->ID, 'custom_sidebar', true );
$custom_sidebar = $wp_embed->autoembed( $custom_sidebar ); // Apply oEmbed filter
return $custom_sidebar;
@jeffreyvr
jeffreyvr / MjmlHelper.php
Created March 6, 2018 14:49
Simple helper class for Mjml.
<?php
namespace App\Helpers;
use Config;
class MjmlHelper
{
public static function auth() {
if ( empty( env('MJML_APPID') ) || empty( env('MJML_APPSECRET') ) ) return;
return base64_encode(env('MJML_APPID').':'.env('MJML_APPSECRET'));
@jeffreyvr
jeffreyvr / color-brightness.php
Last active February 15, 2018 14:00
Color brightness rgb
<?php
function color_brightness($hex) {
$hex = str_replace('#', '', $hex);
$strl = strlen($hex)/3;
$c_r = hexdec(substr($hex, 0, $strl));
$c_g = hexdec(substr($hex, $strl, $strl));
$c_b = hexdec(substr($hex, $strl*2, $strl));
$brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
@jeffreyvr
jeffreyvr / wordpress_api_option_groups_categories.js
Last active February 8, 2018 12:22
Make option groups from WordPress API Categories list
var categories = getCategories(); // this function gets the categories with ajax (you'll have to do that yourself ;-))
var html = "";
var tpl_categories = []; // top level categories
var top_cat_count = 0;
for (i = 0; i < categories.length; i++) {
if ( categories[i].parent == 0 ) {
@jeffreyvr
jeffreyvr / access_vba_login.vba
Created January 23, 2018 21:54
Access VBA Login
Option Compare Database
Private Sub LoginBtn_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("select * from dbo_Medewerker where medewerkerloginnaam='" & GebruikersnaamTxt.Value & "'")
If rst.RecordCount <= 0 Then