Skip to content

Instantly share code, notes, and snippets.

View wildiney's full-sized avatar
👋

Wildiney Di Masi wildiney

👋
View GitHub Profile
@wildiney
wildiney / email_error_logs_to_yourself.php
Created June 1, 2013 00:31
Email error logs to yourself
<?php
// Our custom error handler
function nettuts_error_handler($number, $message, $file, $line, $vars){
$email = "
<p>An error ($number) occurred on line
<strong>$line</strong> and in the <strong>file: $file.</strong>
<p> $message </p>";
$email .= "<pre>" . print_r($vars, 1) . "</pre>";
@wildiney
wildiney / automatically_creates_variables_with_the_same_name_as_the_key_in_the_POST_array.php
Created June 1, 2013 00:32
Automatically creates variables with the same name as the key in the POST array
<?php
$username=$_POST["username"];
$age=$_POST["age"];
etc.
?>
<?php
$expected=array('username','age','city','street');
foreach($expected as $key){
if(!empty($_POST[$key])){
@wildiney
wildiney / download_save_a_remote_image_on_your_server_using_PHP.php
Created June 1, 2013 00:33
Download & save a remote image on your server using PHP
<?php
$image = file_get_contents('http://www.url.com/image.jpg');
file_put_contents('/images/image.jpg', $image); //save the image on your server
@wildiney
wildiney / create_data_uri_s.php
Created June 1, 2013 00:34
Create data uri’s
<?php
function data_uri($file, $mime) {
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
}
<?php
function twtreplace($content) {
$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>",$content);
return $twtreplace;
}
add_filter('the_content', 'twtreplace');
add_filter('comment_text', 'twtreplace');
<meta charset="utf-8">
<title>---</title>
<!-- Behavioral Meta Data -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- Core Meta Data -->
<meta name="author" content="---">
<meta name="description" content="---">
<?php
function __my_registration_redirect(){
return home_url( '/my-page' );
}
add_filter( 'registration_redirect', '__my_registration_redirect' );
<?php
add_filter( 'jpeg_quality', 'smashing_jpeg_quality' );
function smashing_jpeg_quality() {
return 100;
}
<?php
add_action( 'init', 'smashing_session_start' );
function smashing_session_start() {
if ( !session_id() ) {
session_start();
}
}