Skip to content

Instantly share code, notes, and snippets.

@azizultex
azizultex / Getting All Contact Form 7 Forms in a Select Option and Showing Selected Form Anywhere Wordpress
Created February 25, 2015 15:20
Getting All Contact Form 7 Forms in a Select Option and Showing Selected Form Anywhere Wordpress
// This is how I listed the forms in Piklist Select Option below:
$args = array('post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1);
$cf7Forms = get_posts( $args );
// $post_ids = wp_list_pluck( $cf7Forms , 'ID' );
$form_titles = wp_list_pluck( $cf7Forms , 'post_title' );
piklist('field', array(
'type' => 'group'
,'field' => 'contact_form'
@rnagle
rnagle / wpdb_default_tables.sql
Last active March 28, 2024 22:37
Default WordPress Database Table Create Statements
DROP TABLE IF EXISTS wp_users;
CREATE TABLE wp_users (
ID bigint(20) unsigned NOT NULL auto_increment,
user_login varchar(60) NOT NULL default '',
user_pass varchar(64) NOT NULL default '',
user_nicename varchar(50) NOT NULL default '',
user_email varchar(100) NOT NULL default '',
user_url varchar(100) NOT NULL default '',
user_registered datetime NOT NULL default '0000-00-00 00:00:00',
user_activation_key varchar(60) NOT NULL default '',
@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
@jvanderwee
jvanderwee / YouTubeHelper.java
Created August 5, 2015 16:39
Extract video id from YouTube url in java
import com.google.inject.Singleton;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Singleton
public class YouTubeHelper {
final String youTubeUrlRegEx = "^(https?)?(://)?(www.)?(m.)?((youtube.com)|(youtu.be))/";
final String[] videoIdRegex = { "\\?vi?=([^&]*)","watch\\?.*v=([^&]*)", "(?:embed|vi?)/([^/?]*)", "^([A-Za-z0-9\\-]*)"};
@yang-wei
yang-wei / phpbrew-config.md
Created October 28, 2015 04:44
How to use switch PHP(using phpbrew) version in nginx config
php -v
PHP 5.6.3 (cli) (built: Oct 28 2015 09:47:41)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

But this only changes in CLI. You have to tweak you nginx(same for apache) to make it works. Nginx will still using the native PHP-FPM.

> ps aux | grep php-fpm
@hollodotme
hollodotme / Install-php7.md
Last active January 22, 2026 06:00
Installing php7-fpm with phpredis and xdebug extension on Ubuntu 14.04

Install php7.0-fpm

# remove php5 modules
apt-get autoremove --purge php5-*
# add php-7.0 source list by [Ondřej Surý](https://github.com/oerdnj)
add-apt-repository ppa:ondrej/php
# Update index
apt-get update
# Install php7.0-fpm with needed extensions
@jaysoo
jaysoo / hiding-components-in-react-native.js
Last active June 8, 2023 14:54
How to hide a component in react-native
/*
* UPDATE: Looked at the blame, turns out the negative bottom is actually for ensuring layout doesn't change during transitions.
* Still don't know how that works completely, but it has nothing to do with hiding (top: window.height pushes view out of viewport).
*
* I was just looking at Navigator implementation and noticed this line:
* https://github.com/facebook/react-native/blob/master/Libraries/CustomComponents/Navigator/Navigator.js#L110-L113
*
*/
import React, {
Component,
@odan
odan / xampp_php7_xdebug.md
Last active February 26, 2026 18:45
Installing Xdebug for XAMPP
@sergioccrr
sergioccrr / fb.php
Created January 3, 2016 14:51
Check if a request is from Facebook Crawler
<?php
function check_facebook() {
$IP = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false;
$UA = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : false;
if (!$IP || !$UA) return false;
$UAs = ['facebookexternalhit', 'Facebot', 'visionutils'];
$UAs = array_map('preg_quote', $UAs);
if (!preg_match('#^' . implode('|', $UAs) .'#i', $UA)) return false;
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active February 25, 2026 03:40
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files: