Skip to content

Instantly share code, notes, and snippets.

View Sikwan's full-sized avatar

François Vanderkelen Sikwan

View GitHub Profile
class Dimension {
constructor(entry) {
Object.assign(this, entry);
}
}
Dim = new Mongo.Collection('dimensions', {
transform: function(entry) {
return new Dimension(entry);
}
@Sikwan
Sikwan / Javascript: Json to Download CSV
Created December 18, 2012 10:30
Allow the browser to transform a JSON to CSV and Download it. Base version from : http://www.zachhunter.com/2010/11/download-json-to-csv-using-javascript/
function Json2CSV(objArray)
{
var
getKeys = function(obj){
var keys = [];
for(var key in obj){
keys.push(key);
}
return keys.join();
}, objArray = format_json(objArray)
@Sikwan
Sikwan / DataTables - Serialize
Created October 26, 2012 12:26
Javascript - JQuery DataTables - Form Serialize
var oTable;
$(document).ready(function() {
$('#form').submit( function() {
var sData = $('input', oTable.fnGetNodes()).serialize();
alert( "The following data would have been submitted to the server: \n\n"+sData );
return false;
} );
oTable = $('#example').dataTable();
@Sikwan
Sikwan / PHP - Spypixel
Created August 16, 2012 15:55
PHP : Generate 1x1 Gif Spypixel
<?php
header('Content-Type: image/gif');
echo base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==');
?>
@Sikwan
Sikwan / twig_debug
Created June 15, 2012 14:06
YAML : Activate Twig Debug
{# config_dev.yml #}
twig:
debug: 1
services:
twig.extension.debug:
class: Twig_Extensions_Extension_Debug
tags:
- { name: 'twig.extension' }
@Sikwan
Sikwan / collection_widget.twig
Created June 15, 2012 09:53 — forked from cowlby/collection_widget.twig
Customizing form collections in Symfony2
{% block collection_widget %}
{% spaceless %}
<div class="collection">
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}
<ul>
{% for rows in form %}