Skip to content

Instantly share code, notes, and snippets.

@JackNUMBER
JackNUMBER / currencyPattern.js
Created March 2, 2017 17:06
Get Currency Symbol Position
// this script return the currency symbol position (before/after) depending of the locale
const getCurrencySymbolPosition = function (locale, currency) {
let currencyString = new Intl.NumberFormat(locale, {
style: "currency",
currency: currency,
currencyDisplay: "code"
}).format(99); // number doesn't matter here
if (currencyString.slice(0, 3) == currency) {
@JackNUMBER
JackNUMBER / promise_template.js
Last active November 26, 2020 20:06
Javascript Promise template
'use strict';
function testPromise() {
// synchrone
var my_promise = new Promise(
function(resolve, reject) {
// asynchrone
if (true) {
@JackNUMBER
JackNUMBER / konami.js
Created February 25, 2016 01:01
Vanilla JS Konami Code
var user_keys = [],
konami = '38,38,40,40,37,39,37,39,66,65';
document.onkeydown = function(e){
user_keys.push(e.keyCode)
if (user_keys.toString().indexOf(konami) >= 0) {
console.log('KONAMI!');
user_keys = [];
}
}
@JackNUMBER
JackNUMBER / breakpoint.scss
Last active February 25, 2016 01:02
Very simple SCSS breakpoint mixin
@mixin bp($width) {
@media screen and (min-width: $width) {
@content;
}
}
.block {
width: 100%;
@include bp(970px) {
@JackNUMBER
JackNUMBER / gist:20cdc70403ed6c80c3e8
Last active August 29, 2015 14:23
[Wordpress] Required plugin
/* in functions.php */
// Admin messages
function show_admin_messages() {
$plugin_messages = array();
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
// Requiered plugins
if(!is_plugin_active('advanced-custom-fields/acf.php')) {
@JackNUMBER
JackNUMBER / gist:60b4001228fd5c02229c
Created June 20, 2015 13:29
[Wordpress] Remove emoji/emoticons external script
<?
/* in functions.php*/
// remove emoticons external script
remove_action('wp_head', 'print_emoji_detection_script', 7);
// remove completely CSS/JS scripts (new emoticons are always enabled)
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
@JackNUMBER
JackNUMBER / gist:5525715305c8443a9d5e
Last active August 29, 2015 14:06
[Wordpress] Auto-empty trash
<?
/* add one of this lines in WP-config.php (before Auth key) */
// Define number of days old to empty trash
define('EMPTY_TRASH_DAYS', 3);
@JackNUMBER
JackNUMBER / gist:0f67aa3a2b53986752f6
Last active August 29, 2015 14:06
[Wordpress] Change revision parameters
<?
/* add one of this lines in WP-config.php (before Auth key) */
/** Define revision number */
define('WP_POST_REVISIONS', 10);
/** Disabled revision */
define('WP_POST_REVISIONS', false);
@JackNUMBER
JackNUMBER / gist:0846f746eedb78428712
Created September 8, 2014 14:50
[Wordpress] Clean the head
<?
/* add this in functions.php */
// remove elements from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
@JackNUMBER
JackNUMBER / gist:4f510f6b04b34ac123dd
Last active August 29, 2015 14:06
[Wordpress] Avoid auto <p>
<?
/* add this in functions.php */
// avoid auto <p>
remove_filter('the_content', 'wpautop');