Skip to content

Instantly share code, notes, and snippets.

View xewl's full-sized avatar
👁️‍🗨️

Ken Verhaegen xewl

👁️‍🗨️
View GitHub Profile
@tankbar
tankbar / wp-google-tag-manager
Last active January 23, 2024 11:17
Add Google Tag Manager in WordPress with hooks and actions
<?php
/* ADD GTM TO HEAD AND BELOW OPENING BODY */
add_action('wp_head', 'google_tag_manager_head', 20);
function google_tag_manager_head() { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
@jhoff
jhoff / Enums.php
Last active August 27, 2024 09:51
Laravel Model Enumeration Trait
<?php
namespace App\Traits;
use Illuminate\Support\Str;
use App\Exceptions\InvalidEnumException;
trait Enums
{
/**
@yassermog
yassermog / MY_Input.php
Last active August 1, 2018 10:00 — forked from nambok/MY_Input.php
Extends codeigniter input class to accept put and delete requests ........ Just Put this file in application/core/MY_Input.php ........ NOW you can $data=$this->input->put('key');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Input extends CI_Input {
/**
* Variables
*
*/
protected $delete;
@fletcherist
fletcherist / CpuMeter.js
Created October 11, 2017 15:13
CPU Metrics for Chrome Extensions
((name, context = window, func) => { context[name] = func() })
('CpuMeter', this, () => {
const isEmptyObject = object => Object.keys(object).length === 0
const getProcessorUsage = (usage, oldUsage) =>
Math.floor((usage.kernel + usage.user - oldUsage.kernel - oldUsage.user) / (usage.total - oldUsage.total) * 100)
class CpuMeter {
constructor() {
if (!chrome || !chrome.system || !chrome.system.cpu) {
throw new Error(`No access to chrome.system.cpu!
@ekrist1
ekrist1 / Tabs.vue
Created October 18, 2017 19:14
Vue Bulma Laravel Tabs
<template>
<div>
<div class="tabs">
<ul>
<li v-for="tab in tabs" :key="tab.id" :class="{ 'is-active': isActivated(tab) }"><a @click="selectTab(tab)">{{ tab.name }}</a></li>
</ul>
</div>
</div>
</template>
@Phoenix2k
Phoenix2k / wordpress-custom-tax-columns.php
Created December 12, 2017 14:13
WordPress: Custom taxonomy columns with sorting support
<?php
/**
* This example uses 'main-category' as a custom taxonomy and values
* from Carbon Fields for sorting https://carbonfields.net
*/
// Add custom column title
add_filter( 'manage_edit-main-category_columns', function( $columns ) {
$column_position = 2;
$before = array_slice( $columns, 0, $column_position, true );
@spacepatcher
spacepatcher / Breach Compilation (1.4 billion credentials) in Postgres.md
Last active April 8, 2025 15:34
Breach Compilation (1.4 billion credentials) in Postgres.md
@devotoare
devotoare / .user.ini
Created March 21, 2018 00:52
Wordfence for Trellis/Bedrock
; Wordfence WAF
auto_prepend_file = ‘/srv/www/example.com/current/config/wordfence-waf.php’
; END Wordfence WAF
// On PhpStorm, when ussing with laravel mix, for Alias path resolving in components you have to:
// - create a webpack.config.js file separately like:
const path = require('path')
const webpack = require('webpack')
module.exports = {
...
resolve: {
extensions: ['.js', '.json', '.vue'],
@wdmtech
wdmtech / trim-strings-in-laravel-model-on-save.md
Last active August 18, 2023 14:55
Trim all strings in a Laravel Model before they are saved
public static function boot() {
    parent::boot();

    // Trim all string attributes before they are saved
    static::saving(function($model){
        $attributes = collect($model->getAttributes())->map(function ($attribute) {
            if (is_string($attribute)) {
                return trim($attribute);
 }