Skip to content

Instantly share code, notes, and snippets.

@partageit
partageit / blueimp-yeoman-angularjs-Uploader-v2.js
Created September 16, 2014 19:22
Partage-it.com : le contrôleur d'upload amélioré pour blueimp-file-upload
'use strict';
angular.module('testBlueimpApp')
.controller('UploaderCtrl', function ($scope, fileUpload) {
var baseUrl = 'http://localhost/test-upload/index.php';
$scope.options = {
autoUpload: true,
maxChunkSize: 1024 * 1024, // = 1Mo
add: function(e, data) {
@partageit
partageit / loginControllers.js
Last active August 29, 2015 14:06
Partage-it.com : transformation de callback en promises
'use strict';
angular.module('promiseTestApp')
.controller('LoginWithCallbacksCtrl', function ($scope, Connection) {
$scope.connect = function(login, password) {
$scope.showLoader();
Connection.get(
{'login': login, 'password': password},
function() { // success
$scope.notification('Connection successful');
@partageit
partageit / functions-bootstrap-grid-shortcode.php
Created October 17, 2014 08:34
Partage-it.com : ajouter un système de colonnes responsives par shortcode pour WordPress
<?php
/**
* Shortcodes to create responsive columns in the WordPress content, using Twitter Bootstrap.
* For further details about sizes, offset and clearfix, take a look at http://getbootstrap.com/css/#grid
*/
/**
* Shortcode to add a row containing columns
* Parameters:
* - classes: additional classes
@partageit
partageit / gmtToLocaleDate.js
Created November 1, 2014 21:30
Translate GMT date to browser's timezone, with locale format
/**
* Get a date as 'YYYY-MM-DD HH:MM:SS' as GMT, and returns the same date according to the browser's timezone, i.e. GMT+n.
* The returned date is a string, with the locale format.
* @param string dateString The date as 'YYYY-MM-DD HH:MM:SS'
* @param bool withHour If false (default), the 'hour' part is excluded from the returned string
* @return string The date/time according to the browser's locale timezone and format.
* @example gmtToLocaleDate('2014-10-31 21:52:17', true) returns '31/10/2014 21:52:17' (according to my French browser locale, as october is GMT+1)
* @example gmtToLocaleDate('2014-05-31 21:52:17', true) returns '31/05/2014 23:52:17' (as May is GMT+2)
*/
var gmtToLocaleDate = function(dateString, withHour) {
@partageit
partageit / Gruntfile-copy-font-files.js
Last active August 29, 2015 14:08
Partage-it.com : inclure les fichiers font (de Font Awesome par exemple) avec grunt build (avec yo angular par exemple)
[...]
// The following *-min tasks produce minified files in the dist folder
cssmin: {
options: {
root: '' // customisation to add font files from CSS libraries
}
},
[...]
copy: {
@partageit
partageit / getCleanObject.js
Created November 26, 2014 09:58
Returns a clean copy of the provided object, in order to JSON.stringify it for example
'use strict';
/**
* Returns a clean copy of the provided object, in order to JSON.stringify it for example.
*
* It removes recursively methods and cyclic objects.
* Cyclic objects are references to a parent object of the property, for example: a.b.c = a;
* References to non-parent objects are kept, for example: a.b.c = 'hello'; a.d = a.b;
* @param any obj Any variable. When obj is not an object, it is returned as-is.
* @param array parents Parents list, for internal use.
@partageit
partageit / src-UsersManager.php
Last active August 29, 2015 14:13
Partage-it.com : création d'une classe pour son utilisation en tant que mock avec Atoum en PHP
<?php
// src/UsersManager.php
namespace Vendor\Users;
class UsersManager {
private $users = array();
/**
* Add a user to the list
* @return User|boolean Return the created user object, or false if the user is not valid
@partageit
partageit / CodeIndentationShifter.php
Created January 26, 2015 16:55
Code indentation shifter : Shift code to the left, preserving indentation
<?php
/**
* Shift code to the left, preserving indentation.
*
* This is useful when reading code extract in a not-displayed nested structures.
* There is no use of closure here in order to remain compatible with older versions of PHP.
* This method is code agnostic.
* @example
* $code = "";
* $code .= " while ($a) {";
@partageit
partageit / functions-bootstrap-carousel-shortcode.php
Last active September 4, 2015 12:25
Partage-it.com : Carrousel d'articles pour WordPress avec Twitter Bootstrap
@partageit
partageit / functions-gallery.php
Last active October 14, 2015 04:13
Partage-it.com : changer l'apparence des galeries