Skip to content

Instantly share code, notes, and snippets.

View yoanmarchal's full-sized avatar
💭
I may be slow to respond.

Marchal yoan yoanmarchal

💭
I may be slow to respond.
View GitHub Profile
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
function get_client_language($availableLanguages, $default='en'){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($langs as $value){
$choice=substr($value,0,2);
if(in_array($choice, $availableLanguages)){
return $choice;
}
}
@yoanmarchal
yoanmarchal / pretty_print.php
Created June 27, 2013 12:47
Pretty print - PHP
function pretty_print($arg) {
echo '<pre>';
print_r($arg);
echo '</pre>';
}
/* using pretty print */
$var = $_SERVER;
pretty_print($var);
@yoanmarchal
yoanmarchal / ios-web-app.html
Created June 25, 2013 19:46 — forked from tfausak/ios-8-web-app.html
meta apple / android favicon
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<title>iOS Web App</title>
<!-- iPhone -->
@yoanmarchal
yoanmarchal / responsive.css
Created January 9, 2013 14:01 — forked from arielsalminen/responsive.css
responsive slider css + jquery
#slideshow {
width: 100%;
position: relative;
}
img {
top: 0;
left: 0;
width: 100%;
max-width: 600px;
@yoanmarchal
yoanmarchal / dabblet.css
Created December 18, 2012 20:14 — forked from LeaVerou/dabblet.css
Scrolling shadows by @kizmarh and @LeaVerou
/**
* Scrolling shadows by @kizmarh and @leaverou
* Only works in browsers supporting background-attachment: local; & CSS gradients
* Degrades gracefully
*/
html {
background: white;
font: 120% sans-serif;
}
@yoanmarchal
yoanmarchal / Wordpress add nb views
Last active October 13, 2015 05:37
récupère stock "dans une meta" et montre le nombre de vue par page
//recupere et stock dans une balise meta le nombre de vue par page
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "<p>0 Visite</p>";
}
@yoanmarchal
yoanmarchal / file-upload-handler.php
Created November 20, 2012 13:59 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@yoanmarchal
yoanmarchal / youtube-vimeo-embed-urls.php
Created November 7, 2012 10:50 — forked from cballou/youtube-vimeo-embed-urls.php
PHP Function to Convert Youtube and Vimeo URLs to Lightbox-Ready Equivalents
<?php
/**
* Given a string containing any combination of YouTube and Vimeo video URLs in
* a variety of formats (iframe, shortened, etc), each separated by a line break,
* parse the video string and determine it's valid embeddable URL for usage in
* popular JavaScript lightbox plugins.
*
* In addition, this handler grabs both the maximize size and thumbnail versions
* of video images for your general consumption. In the case of Vimeo, you must
* have the ability to make remote calls using file_get_contents(), which may be
/* normal case */
@font-face {
font-family: "DejaVu Sans";
src: url(‘path-to-font-directory/DejaVuSans.eot’);
src: local(‘☺’), url("path-to-font-directory/DejaVuSans.ttf") format("truetype");
}
/* bold */
@font-face {
font-family: "DejaVu Sans";