Skip to content

Instantly share code, notes, and snippets.

View waltercruz's full-sized avatar
☸️
meditating

Walter Rodrigo de Sá Cruz waltercruz

☸️
meditating
View GitHub Profile
@cipriantepes
cipriantepes / .htaccess
Created August 21, 2017 19:17
GravityForms fix 403 admin-ajax.php
### DISABLE mod_security firewall
### Some rules are currently too strict and are blocking legitimate users
### We only disable it for URLs that contain the regex below
### The regex below should be placed between "m#" and "#"
### (this syntax is required when the string contains forward slashes)
### @src https://stackoverflow.com/questions/12928360/how-can-i-disable-mod-security-in-htaccess-file
<IfModule mod_security.c>
<If "%{REQUEST_URI} =~ "m#/wp-admin/admin.php?page=gf_edit_forms/#">
SecFilterEngine Off
</If>
@phackwer
phackwer / City Model
Created June 7, 2017 17:59
Laravel 5 - all cities, regions, states and countries from Gazeteer
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class City extends Model
{
/**
* @var array
@halian-vilela
halian-vilela / _select2.scss
Created February 23, 2016 17:51
Select2 - Styling Variables
/*
Version: 3.5.4 Timestamp: Sun Aug 30 13:30:32 EDT 2015
*/
$closed-select-bg: $prim-laranja;
$closed-select-text: $sec-branco;
$closed-border: none;
$border-focus-color: transparent;
$border-focus-shadow-color: rgba(233, 102, 102, 0.7);
$opened-select-bg: $sec-rosa;
@ashevchuk
ashevchuk / gist:8e9d43277f30ffb993d5
Last active May 5, 2016 01:45
FreeBDS installation process @cloudatcost VPS provider
For example, we need two VMs in the same network:
104.1.1.5 - debian linux
104.1.1.6 - host, where we want to install FreeBSD
00:50:66:be:70:c9 - ethernet address, where we installing FreeBSD
Network:
104.1.1.0 - our network
255.255.255.0 - our network mask
104.1.1.255 - our network broadcast address
104.1.1.1 - our network gateway
// Diatonic Chord Trigger
var notes = ["C", "C#/Db", "D", "D#/Eb", "E", "F", "F#/Gb", "G", "G#/Ab", "A", "A#/Bb", "B"];
var PluginParameters = [
{ name: "Parent Key", type: "menu", valueStrings:notes, defaultValue: 0 }
];
var debug = true;
function rootKey() {
return GetParameter("Parent Key");
@halian-vilela
halian-vilela / wp_menu_call.php
Created January 3, 2014 18:26
WP menu config
<?php
function wp_menu_call($menu_name){
wp_nav_menu
( array
(
'theme_location' => $menu_name, // as defined by "register_nav_menu( 'Menu-Handle', 'Menu Label')", located in functions.php
'menu' => '',
'container' => 'nav', // "div" or "nav" (use "nav" for HTML5)
'container_class' => $menu,
@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@ches
ches / install-pygtk.sh
Created July 20, 2011 11:34
Install PyGTK via Homebrew and virtualenv
# This LOOKS pretty straightforward, but it took awhile to sort out issues with
# py2cairo and pygobject, so I hope I've saved you some time :-)
#
# This assumes you already subscribe to a nice clean virtualenvwrapper workflow
# -- see https://gist.github.com/771394 if you need advice on getting there.
# There are some optional dependencies omitted, so if you're going to be doing
# heavy development with these libs, you may want to look into them.
#
# We go to some configure option pains to avoid polluting the system-level
# Python, and `brew link`ing Cairo which is keg-only by default.