Skip to content

Instantly share code, notes, and snippets.

View lohic's full-sized avatar

Loïc Horellou lohic

View GitHub Profile
<?php
/**
* Script to clean up unused fields in page or file content files
* Compares fields present in the content file
* with fields defined in the blueprint
* and removes all undefined fields
*/
require __DIR__ . '/kirby/bootstrap.php';
@lohic
lohic / com.apple.ibooks.display-options.xml
Last active August 29, 2015 14:26
To force embed police when viewing pub on apple ibooks
<?xml version="1.0" encoding="UTF-8"?>
<display_options>
<!-- Supported values for platform name: "*", "iphone", "ipad"; "iphone" applies to ipod touch as well; note all-lowercase -->
<platform name="*">
<!-- allowed values for "fixed-layout" are either "true" or "false" (with "false" as the default when unspecified) -->
<option name="fixed-layout">false</option>
<!-- allowed values for "open-to-spread" are either "true" or "false" (with "false" as the default when unspecified) -->
<option name="open-to-spread">false</option>
<option name="specified-fonts">true</option>
</platform>
<?php
/**
* Supprimer les accents
*
* @param string $str chaîne de caractères avec caractères accentués
* @param string $encoding encodage du texte (exemple : utf-8, ISO-8859-1 ...)
*/
function suppr_accents($str, $encoding='utf-8')
{
// transformer les caractères accentués en entités HTML
@lohic
lohic / in_array.java
Last active August 29, 2015 14:02
in_array for processing
import java.util.Arrays;
void setup() {
String[] tableau = {
"test", "youpi", "apple"
};
println(in_array("rien", tableau));
}
@lohic
lohic / ajax-abort.js
Last active August 29, 2015 14:02
ajax abort
$.xhrPool = [];
$.xhrPool.abortAll = function() {
$(this).each(function(idx, jqXHR) {
jqXHR.abort();
});
$(this).each(function(idx, jqXHR) {
var index = $.inArray(jqXHR, $.xhrPool);
if (index > -1) {
$.xhrPool.splice(index, 1);
}
@lohic
lohic / ajax-progress.js
Last active August 29, 2015 14:02
ajax progress bar
// http://www.dave-bond.com/blog/2010/01/JQuery-ajax-progress-HMTL5/
$.ajax({
xhr: function()
{
var xhr = new window.XMLHttpRequest();
//Upload progress
xhr.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
@lohic
lohic / duotone.php
Created May 16, 2014 22:27
RGB bichromie
<?php
// cf http://www.tuxradar.com/practicalphp/11/2/21
function duotone (&$image, $rplus, $gplus, $bplus) {
$imagex = imagesx($image);
$imagey = imagesy($image);
for ($x = 0; $x <$imagex; ++$x) {
for ($y = 0; $y <$imagey; ++$y) {
@lohic
lohic / breadcrumb.php
Created May 12, 2014 19:56
wordpress breadrumb
<?php
/**
* BREADCRUMB
* @return [type] [description]
*/
function dimox_breadcrumbs() {
$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>HTML5 Full-Screen Demonstration</title>
<style>
*
{
padding: 0;
margin: 0;
<?php
$args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'numberposts' => null, 'post_parent' => $post->ID );
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
$image_title = $attachment->post_title;
$caption = $attachment->post_excerpt;
$description = $image->post_content;
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) { ?>
<a href="<?php echo wp_get_attachment_url( $attachment->ID, false ); ?>" rel="lightbox" title="<?php echo $image_title; ?>"><img src="<?php bloginfo('template_url'); ?>/timthumb.php?h=75&w=75&zc=1&src=<?php echo wp_get_attachment_url( $attachment->ID , false ); ?>" alt="" width="75" height="75" border="0" /></a>