Skip to content

Instantly share code, notes, and snippets.

View beatwiz's full-sized avatar
🥶
#crunching

Gustavo Silva beatwiz

🥶
#crunching
View GitHub Profile
@RaVbaker
RaVbaker / readme.md
Created March 30, 2012 20:12
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@joyrexus
joyrexus / README.md
Last active June 19, 2024 09:35 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@juyal-ahmed
juyal-ahmed / wp-featured-image-upload-for-front-end.php
Last active February 21, 2018 03:48
Upload featured image on custom post from WordPress front-end
@mattclements
mattclements / function.php
Last active July 2, 2024 15:32
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@davidrushton
davidrushton / Kernel.php
Created February 17, 2016 17:29
Laravel 5 Database Queue - Shared Hosting
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
@edheltzel
edheltzel / php-server-with-wordpress.md
Last active November 26, 2020 21:33
Using PHP's built in server for WordPress development.

Preface

So in the past, I've used MAMP/MAMP Pro apps and others alike. I've also, setup my own local MAMP stack with homebrew, that used dnsmasq to dynamically add vhosts anytime I added a new folder to the Sites folder which made it very convenient. But, then I started running into other environment issues with PHP versions on remote machines/servers not being updated or some other crazy thingamabob breaking. I researched and invested time in Vagrant, but that seem to break more often than my homebrew setup. So I researched again investing time into Docker via Docker for Mac (which is BAMF), which I'm sold on and use daily, but it still seems a little bleeding edge and not so simple to wrap your head around the concept. Not to mention I don't have a real use case to play with and take advantage of all the features that come packed with Docker.

This is the beginning of trying to find something more simple, and slightly quicker to setup.

@jsn789
jsn789 / add-gtm-wp.php
Last active March 28, 2023 15:38
Add Google Tag Manager through functions.php in WordPress
/* Add Google Tag Manager javascript code as close to
the opening <head> tag as possible
=====================================================*/
function add_gtm_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=
@mpryvkin
mpryvkin / beautify-html.js
Last active August 6, 2020 15:46 — forked from brnpimentel/beautify-html.js
JS Beautify hack to work with Blade directives (Laravel)
function Beautifier(html_source, options, js_beautify, css_beautify) {
//Wrapper function to invoke all the necessary constructors and deal with the output.
html_source = html_source || '';
// BEGIN
html_source = html_source.replace(/\{\{((?:(?!\}\}).)+)\}\}/g, function (m, c) {
if (c) {
c = c.replace(/(^[ \t]*|[ \t]*$)/g, '');
c = c.replace(/'/g, '&#39;');
c = c.replace(/"/g, '&#34;');
@nicomollet
nicomollet / acf-disable-autocomplete.php
Created July 26, 2018 15:03
ACF Disable Autocomplete on input and textarea fields
<?php
/**
* ACF Disable Autocomplete on input and textarea fields
* Chrome ignores autocomplete="off" in some cases
*
* @author Nicolas Mollet
* @link https://bugs.chromium.org/p/chromium/issues/detail?id=468153
*/
function acf_input_disable_autocomplete() {
@yojona
yojona / countries_codes_and_coordinates.json
Last active December 4, 2020 17:04 — forked from tadast/countries_codes_and_coordinates.csv
Countries with their (ISO 3166-1) Alpha-2 code, Alpha-3 code, UN M49, average latitude and longitude
[
{
"country": "Afghanistan",
"alpha_2_code": "AF",
"alpha_3_code": "AFG",
"numeric_code": 4,
"latitude": 33,
"longitude": 65
},
{