Skip to content

Instantly share code, notes, and snippets.

View luxifer's full-sized avatar
:shipit:
Gopher of the GitHub swamp

Florent Viel luxifer

:shipit:
Gopher of the GitHub swamp
View GitHub Profile
@luxifer
luxifer / index.php
Created March 28, 2012 15:13
php controller in 14 lines
<?php
if (!empty($_GET['p']))
{
if (is_file($_GET['p'].".php"))
{
include($_GET['p'] . ".php");
}
else
{
echo 'error';
@luxifer
luxifer / MailAttachmentManager.class.php
Created August 2, 2012 08:40
Mail Attachment management
<?php
/**
* @author Florent Viel
*/
class MailAttachmentManager
{
/**
* @var string {host:port\params}BOX voir http://fr.php.net/imap_open
*/
@luxifer
luxifer / demo.php
Created August 2, 2012 08:56
Mail Attachment management demo
#!/usr/bin/env php
<?php
require_once("attachmentread.class.php");
$host="{host:port/params}BOX"; // voir http://fr.php.net/imap_open
$login=""; //imap login
$password=""; //imap password
$savedirpath="./" ; // attachement will save in same directory where scripts run othrwise give abs path
$jk=new MailAttachmentManager($host, $login, $password, $savedirpath); // Creating instance of class####
?>
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
<?php
$start_request = microtime(true);
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('front', 'dev', true);
sfContext::createInstance($configuration)->dispatch();
$enable_graphite = sfConfig::get('app_enable_graphite');
function modifieTexte() {
var t2 = document.getElementById("t2");
t2.firstChild.nodeValue = "trois";
}
function load() {
var el = document.getElementById("t");
el.attachEvent("onclick", modifieTexte);
}
function modifieTexte() {
var t2 = document.getElementById("t2");
t2.firstChild.nodeValue = "trois";
}
function load() {
var el = document.getElementById("t");
el.addEventListener("click", modifieTexte, false); //ne marche pas
}
fviel@grievous ⮀ ~/git/newkozikaza ⮀ ⭠ master ⮀ ls -l vendor/composer
total 164
-rw-r--r-- 1 fviel users 1320 7 mai 14:16 autoload_classmap.php
-rw-r--r-- 1 fviel users 5674 7 mai 14:16 autoload_namespaces.php
-rw-r--r-- 1 fviel users 1380 7 mai 14:16 autoload_real.php
-rw-r--r-- 1 fviel users 6857 7 mai 14:16 ClassLoader.php
-rw-r--r-- 1 fviel users 139733 7 mai 14:16 installed.json
fviel@grievous ⮀ ~/git/newkozikaza ⮀ ⭠ master ● ⮀
@luxifer
luxifer / bench.php
Created May 22, 2013 12:23
bench concaténation
<?php
function benchStrintf() {
$begin = microtime(true);
for ($i=0; $i<1000000; $i++) {
$result = sprintf('%d = %d + %d selon %s', 42, 11, 31, 'php');
}
var_dump(microtime(true)-$begin);
}
<?php
/**
* TimThumb by Ben Gillbanks and Mark Maunder
* Based on work done by Tim McDaniels and Darren Hoyt
* http://code.google.com/p/timthumb/
*
* GNU General Public License, version 2
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Examples and documentation available on the project homepage