Skip to content

Instantly share code, notes, and snippets.

@zofe
zofe / rpd_breadcrumb
Last active December 17, 2015 11:49
a simple !? breadcrumb for wordpress hugs
/**
* wordpress breadcrumb function
*
* @author Felice Ostuni <[email protected]>
* @param tring $domain for translations (usually your theme folder name)
*/
function rpd_breadcrumbs($domain=null) {
global $post;
old style autocompleter
$acvetrina = new autocompleter_field(array('name'=>'acvetrina','status'=>'modify'));
$acvetrina->ajax_source = site_url('admin/feedback/js_vetrine');
$acvetrina->min_chars = '2';
$acvetrina->record_label = 'vetrina';
$acvetrina->record_id = 'ID';
$acvetrina->hidden_field_id = 'id_vetrina';
$acvetrina->extra_params = "category: function() { return $('#id_categoria').val() } , prov: function() { return $('#id_provincia').val() }";
$acvetrina->build();
@zofe
zofe / errors.php
Last active December 24, 2015 21:59
to remember:sometime error_log is just better than ..debug, var_dump or die
error_log(print_r($var, true), 3, $_SERVER['DOCUMENT_ROOT']."/uploads/log.txt");
var_dump($var);
die($var);
@zofe
zofe / grab.php
Last active August 30, 2016 04:30
grab page with polipo and tor
<?php
function grab_page($url, $data=array())
{
$agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1';
$referer = "http://www.bing.com";
$url = str_replace(' ', '%20', $url);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
<?php
/**
* A simple Facebook PHP example.
*
* - This is not a "Facebook SDK".
* - This example uses Curl, Hash, JSON, Session extensions.
* - This does not use the JavaScript SDK, nor the cookie set by it.
* - This works with Canvas, Page Tabs with IFrames, the Registration Plugin
* and with any other flow which uses the signed_request.
<?php
class Tag extends Eloquent
{
public function scopeSearch($query, $q)
{
$match = "MATCH(`tag`, `varianti`) AGAINST (?)";
return $query->whereRaw($match, array($q))->orderByRaw($match.' DESC', array($q));
}
@zofe
zofe / Site.php
Last active August 29, 2015 13:57
<?php
class Site
{
protected static $assets = array();
public static function assets()
{
$arr = func_get_args();
<?php
class HomeController extends BaseController
{
public function showWelcome()
{
$articoli = Articolo::Articoli()->Pubblici()->take(4)->remember(10)->get();
$primopiano = $articoli->shift();
<?php namespace Zofe\Filters;
/*
my customized version of jeff class https://laracasts.com/lessons/caching-essentials
*/
use Illuminate\Routing\Route;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Str;
## timthumb
http://timthumb.googlecode.com/svn/trunk/timthumb.php
(download and configure cache path)
## .htaccess
RewriteRule ^thumb/(\d+)x(\d+)/f(\d)/q(\d{2})/(.*) /public/images/timthumb.php?src=/$5&w=$1&h=$2&f=$3&q=$4 [L]
RewriteRule ^thumb/(\d+)x(\d+)/f(\d)/(.*) /public/images/timthumb.php?src=/$4&w=$1&h=$2&f=$3 [L]
RewriteRule ^thumb/(\d+)x(\d+)/(.*) /public/images/timthumb.php?src=/$3&w=$1&h=$2 [L]