Skip to content

Instantly share code, notes, and snippets.

View devuri's full-sized avatar
🏠
Working from home

uriel devuri

🏠
Working from home
View GitHub Profile
@devuri
devuri / looper.php
Created November 11, 2016 15:46 — forked from Kiyumars/looper.php
Youtube looper
<?php
if (isset($_POST['video_req']) && ! empty($_POST['video_req'])){
if ( preg_match("+youtube.com+", $_POST['video_req']) ) {
$video = htmlspecialchars($_POST['video_req']);
$strpos_yt = strpos($video, "youtube.com");
$beginning = substr($video, 0, $strpos_yt) ;
if ($beginning != "http://www." )
{$video = substr_replace ($video, "http://www.", 0, $strpos_yt ) ;}
@devuri
devuri / switch-theme.php
Created November 18, 2016 17:21 — forked from dbernar1/switch-theme.php
Switch theme based on whether the user is logged in or not. One theme for guests, other theme for logged in users.
<?php
/**
* Plugin name: Different theme for guest than logged in user
*/
// You can also put this file in mu-plugins dir.
add_filter( 'template', 'switch_theme__db' );
add_filter( 'stylesheet', 'switch_theme__db' );
@devuri
devuri / backup_droplet.php
Created December 16, 2016 13:44 — forked from VovanZver/backup_droplet.php
Backup droplet
<?php
class BackupDroplet
{
private $apiUrl = 'https://api.digitalocean.com/v2/';
private $token;
private $dropletId;
public function __construct($token, $dropletId)
{
@devuri
devuri / README-Template.md
Created January 31, 2017 16:10 — forked from NZenitram/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@devuri
devuri / README-Template.md
Created January 31, 2017 16:15 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@devuri
devuri / http.php
Created April 14, 2017 00:21
simple http request example in php
<?php
/*
* simple HttpRequest example using PHP
* tom slankard
*/
class HttpRequest {
public $url = null;
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @param boolean $asHash Use header row as keys in the returned array
@devuri
devuri / basichook.php
Created September 7, 2017 11:13 — forked from danielpataki/basichook.php
Getting Started With Plugins
function my_tracking_code() {
echo 'Paste tracking code from Google Analytics here';
}
add_action( 'wp_footer', 'my_tracking_code' );
@devuri
devuri / set-value.md
Created October 7, 2017 13:37 — forked from JeffreyWay/set-value.md
PHP: Set value if not exist

You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:

name = name || 'joe';

This is quite common and very helpful. Another option is to do:

name || (name = 'joe');