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

<?php
// shortcode
add_shortcode( 'foobar', 'foobar_func' );
function foobar_func( $atts ){
// php only
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 3,
@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;
@devuri
devuri / dve_csv_prettyarray.php
Created September 1, 2017 05:15
convert a csv file to array very pretty
<?php
function dve_csv_array($csvfile = 'samplecasvdata.csv',$cn=0,$before = '<br/>',$after = '<br/>'){
$csv = array_map('str_getcsv', file($csvfile));
foreach($csv as &$cell){
echo $before.$cell[$cn].$after;
}