Skip to content

Instantly share code, notes, and snippets.

View nr1q's full-sized avatar

Enrique nr1q

View GitHub Profile
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@ryansechrest
ryansechrest / php-style-guide.md
Last active April 21, 2024 18:50
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@mattclements
mattclements / function.php
Last active April 16, 2024 17:04
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;
}
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@maxtruxa
maxtruxa / Antonyms.md
Last active April 3, 2024 22:51
A list of common terms used in programming and their respective antonyms.

Antonym List

Note: The table headings (positive/negative) are not necessarily meaningful.

Positive Negative
acquire release
add remove (e.g. an item), subtract (arithmetic)
advance retreat
allocate deallocate (correct), free (common)
allow deny
@jasonm23
jasonm23 / xterm-256color.svg
Last active February 11, 2024 12:33
Xterm 256color mode color chart, organised into sections. (used on Wikipedia/xterm)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<?php
$paises = array("Afganistán","Albania","Alemania","Andorra","Angola","Antigua y Barbuda","Arabia Saudita","Argelia","Argentina","Armenia","Australia","Austria","Azerbaiyán","Bahamas","Bangladés","Barbados","Baréin","Bélgica","Belice","Benín","Bielorrusia","Birmania","Bolivia","Bosnia y Herzegovina","Botsuana","Brasil","Brunéi","Bulgaria","Burkina Faso","Burundi","Bután","Cabo Verde","Camboya","Camerún","Canadá","Catar","Chad","Chile","China","Chipre","Ciudad del Vaticano","Colombia","Comoras","Corea del Norte","Corea del Sur","Costa de Marfil","Costa Rica","Croacia","Cuba","Dinamarca","Dominica","Ecuador","Egipto","El Salvador","Emiratos Árabes Unidos","Eritrea","Eslovaquia","Eslovenia","España","Estados Unidos","Estonia","Etiopía","Filipinas","Finlandia","Fiyi","Francia","Gabón","Gambia","Georgia","Ghana","Granada","Grecia","Guatemala","Guyana","Guinea","Guinea ecuatorial","Guinea-Bisáu","Haití","Honduras","Hungría","India","Indonesia","Irak","Irán","Irlanda","Islandia","Islas Marshall","Islas Salomón
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
'use strict';
class Abstract {
// A static abstract method.
static foo() {
if (this === Abstract) {
// Error Type 2. Abstract methods can not be called directly.
throw new TypeError("Can not call static abstract method foo.");
} else if (this.foo === Abstract.foo) {
// Error Type 3. The child has not implemented this method.
throw new TypeError("Please implement static abstract method foo.");
@hkdobrev
hkdobrev / class-order.php
Last active September 7, 2023 09:08
PHP convention for the order in a class.
<?php namespace Vendor\Library;
use Another\Vendor\Library\ClassName;
abstract class ClassName extends AnotherClass implements Countable, Serializable
{
const CONSTANTS = 'top';
use someTrait, anotherTrait {
anotherTrait::traitMethod insteadof someTrait;