Skip to content

Instantly share code, notes, and snippets.

@partageit
partageit / .bashrc
Created Oct 31, 2017
My bash-git-prompt configuration
View .bashrc
# git prompt, for ~/.bashrc
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_START_USER="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]"
GIT_PROMPT_START_ROOT="${BoldRed}\u@\h${ResetColor}:${BoldBlue}\w${ResetColor}"
GIT_PROMPT_END_USER="\n$ "
GIT_PROMPT_END_ROOT="\n# "
source ~/.bash-git-prompt/gitprompt.sh
@partageit
partageit / reset-websql-database.js
Last active Nov 17, 2019
Reset WebSQL database dropping every tables
View reset-websql-database.js
var db = openDatabase('myDatabase', '', 'My database description', 5 * 1024 * 1024);
if (reinitDb) {
db.changeVersion(db.version, '', function(t) {
t.executeSql("SELECT name FROM sqlite_master WHERE type='table' and name not like '__Webkit%'", [], function(sqlTransaction, sqlResultSet) {
var table, tablesNumber = sqlResultSet.rows.length;
console.log('DATABASE RESET MODE ENABLED');
for (var i = 0; i < tablesNumber; i++) {
table = sqlResultSet.rows.item(i);
console.log('Removing table: ' + table.name);
@partageit
partageit / functions.php
Created May 3, 2016
WooCommerce: enable locale delivery only when minimum amount is reached
View functions.php
<?php
/**
* Disable local delivery when a minimum amount is not reached.
* The minimum amount is the free shipping one.
*/
function setMinimumAmountForLocalDelivery($isAvailable) {
// get cart amount :
if (WC()->cart->prices_include_tax) {
$cartAmount = WC()->cart->cart_contents_total + array_sum(WC()->cart->taxes);
} else {
@partageit
partageit / markdown.css
Created Jan 15, 2016
CSS for markdown-html
View markdown.css
/* This CSS is for markdown-html */
/* markdown-html -s "/path/to/markdown.css" -w "file.md" -o "file.html" */
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
@partageit
partageit / sentora-ssl.conf
Created Oct 26, 2015
Enable SSL for Sentora panel
View sentora-ssl.conf
# <virtualhost *:80> already open
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</virtualhost>
<VirtualHost *:443>
ServerAdmin zadmin@localhost
DocumentRoot "/etc/sentora/panel/"
ServerName your-server-address
@partageit
partageit / slideshow.css
Created Mar 12, 2015
Partage-it.com : transition entre les slides pour remark.js
View slideshow.css
.remark-fading {
z-index: 9;
}
.remark-slide-container {
transition: opacity 1s linear, right 1s ease-in-out;
opacity: 0;
right: 1000px;
}
.remark-visible {
transition: opacity 1s linear, right 1s ease-in-out;
@partageit
partageit / functions-gallery.php
Last active Oct 14, 2015
Partage-it.com : changer l'apparence des galeries
View functions-gallery.php
@partageit
partageit / CodeIndentationShifter.php
Created Jan 26, 2015
Code indentation shifter : Shift code to the left, preserving indentation
View CodeIndentationShifter.php
<?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 / src-UsersManager.php
Last active Aug 29, 2015
Partage-it.com : création d'une classe pour son utilisation en tant que mock avec Atoum en PHP
View src-UsersManager.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 / getCleanObject.js
Created Nov 26, 2014
Returns a clean copy of the provided object, in order to JSON.stringify it for example
View getCleanObject.js
'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.
You can’t perform that action at this time.