Skip to content

Instantly share code, notes, and snippets.

View Zenger's full-sized avatar
⌨️
=

Dennis Zenger Zenger

⌨️
=
View GitHub Profile
@Zenger
Zenger / Javascript
Created June 9, 2012 07:04
Javascript/PHP numbers Only
/* Without jQuery */
/* Example
<input id="myInput" name='credit-card' value='' />
*/
document.getElementById('myInput').onkeyup = function() {
this.value = this.value.replace(/[^\d]/gi , '');
};
@Zenger
Zenger / gist:2988446
Created June 25, 2012 13:01
Wordpress select and order by a meta_value
<?php
$wQuery = new WP_Query(
array('post_type' => 'post',
'posts_per_page' => $how_many,
'cat' => '46,43', // categories should be supplied this way (an array doesn't work)
'meta_key' => 'post_views' ,
'orderby' => 'meta_value_num', // or meta_value (if it's a string)
'order' => 'DESC')
);
@Zenger
Zenger / gist:3175074
Created July 25, 2012 08:22
Snippets
<?php
// checks file mime type, if it's a image.
if ( stristr($mime, "image/") === false)) return false;
?>
@Zenger
Zenger / webfonts.php
Last active October 13, 2015 23:48
A big array of google web fonts
<?php
/*
*
* Google Web Fonts PHP list
* This file has a list of all Google Web Fonts
* Note that it may not be up to date
*
*/
$google_web_fonts = array(array('ABeeZee', 'regular,italic,'),array('Abel', 'regular,'),array('Abril Fatface', 'regular,'),array('Aclonica', 'regular,'),array('Acme', 'regular,'),array('Actor', 'regular,'),array('Adamina', 'regular,'),array('Advent Pro', '100,200,300,regular,500,600,700,'),array('Aguafina Script', 'regular,'),array('Akronim', 'regular,'),array('Aladin', 'regular,'),array('Aldrich', 'regular,'),array('Alegreya', 'regular,italic,700,700italic,900,900italic,'),array('Alegreya SC', 'regular,italic,700,700italic,900,900italic,'),array('Alex Brush', 'regular,'),array('Alfa Slab One', 'regular,'),array('Alice', 'regular,'),array('Alike', 'regular,'),array('Alike Angular', 'regular,'),array('Allan', 'regular,700,'),array('Allerta', 'regular,'),array('Allerta Stencil', 'regular,'),array('Allura', 'regular,'),array('Almendra', 'regular,italic,700,700italic,'),array('Al
@Zenger
Zenger / image-faker.php
Last active December 13, 2015 16:59
Sometimes when working with WordPress web-sites, when moving them you don't really need to download all the uploads folder. Place this script in /wp-content and run it once. It will create a .htaccess file and will take any incoming image requests and render appropriate images. Currently handles filenames like : myimage-150x150.jpg and myimage10…
<?php
/*
Place this script inside the wp-content folder.
Any incoming request for image will be taken over if the requested file doesn't exist.
And will setup a .htacces file to take all incoming requests and send them to this file.
Run it once to setup.
Configure the constants below.
*/
/* Setup Constants */
@Zenger
Zenger / wai.py
Created February 13, 2013 13:12
Downloads, extracts, moves wordpress, creates database for it, and installs wordpress. Needs Python 2.7. Won't work under 3. Uses shutil, urllib. Requires mysql connect. Before using download it at: http://dev.mysql.com/downloads/connector/python/. Config the array at the top. Previous names were, pyg(python generator), pypo(py project), diego a…
#!/usr/bin/env python
# -*- coding: utf8 -*-
# ========= EDIT HERE ======================================================
config = {
# Set the save path
'save_path' : "C:\\VertrigoServ\\www",
'folder_name' : 'dezvoltare',
'title' : 'Dezvoltare',
@Zenger
Zenger / wpxmlrpc.php
Last active December 15, 2015 09:19
WordPress XML-RPC example.
<?php
//https://raw.github.com/dongsheng/cURL/master/curl.class.php
require_once('curl_class.php');
$request = array(
'blog_id' => 1,
'username' => 'username',
'password' => 'password',
'post_id' => 84
@Zenger
Zenger / Slugger.php
Created August 8, 2013 10:56
Slugger.php
<?php
/**
* Slugger, simple logging class
* Writes logs into a file and sends them by e-mail once in a while
* Written for pure example
* @require PHP >= 5.3
* @todo : Fix bug when the class is firt time instantiated it send an empty message
*/
/* Don't forget to setup a date default timezone */
@Zenger
Zenger / Request.php
Last active December 20, 2015 22:59
A simple request class, makes use of CURL.
<?php
class Request {
public $curl_object;
public function __construct($p_username = "", $p_password = "", $p_timeout = 15)
{
$this->curl_object = curl_init();
curl_setopt($this->curl_object, CURLOPT_HTTPHEADER, Array("Accept: application/json", "Content-Type: application/json"));
curl_setopt($this->curl_object, CURLOPT_CONNECTTIMEOUT, $p_timeout);
@Zenger
Zenger / TemplateEngine.php
Last active December 21, 2015 13:58
The laziest possible template engine written in php
<?php
class Template {
static $escape = true;
static $template = "";
static $vars = array();
public static function sanitize($what)
{
return filter_var($what, FILTER_SANITIZE_STRING);