Skip to content

Instantly share code, notes, and snippets.

@a-mt
a-mt / script.sh
Last active April 28, 2026 15:41
SWF to MP4
# Clone convert-swf
$ git clone https://github.com/vsoch/convert-swf.git
$ cd convert-swf
# Build the image
$ docker build -t vanessa/convert-swf .
# Run the container
$ docker run -it --entrypoint '' -v ${PWD}/:/data vanessa/convert-swf bash
@a-mt
a-mt / script.js
Last active November 30, 2018 13:09
MDN Preview Live sample
// Add class text-content to have the proper styles
document.getElementById('content').classList.add('text-content');
// Update header's ID
var headers = document.querySelectorAll('h1,h2,h3,h4,h5,h6');
for(var i=0; i<headers.length; i++) {
var h = headers[i],
id = h.getAttribute('name');
@a-mt
a-mt / index.js
Created March 16, 2018 15:22
Img load bubble
document.body.addEventListener('load', function(e){
if(e.target.tagName == 'IMG'){
e.target.style.visibility = "visible";
}
}, true); // <-- useCapture
@a-mt
a-mt / .eslintrc
Created March 8, 2018 12:32 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@a-mt
a-mt / functions.php
Created May 8, 2017 17:15
Wordpress : Ajouter la recherche dans le menu haut (front)
<?php
/**
* Add the search box to the wordpress header (front)
*/
function add_search_box($nav, $args) {
if($args->theme_location != 'top' ) {
return;
}
ob_start();
get_search_form();
@a-mt
a-mt / index.php
Last active January 28, 2017 06:14
Php : array_rand_proba + array_sort_proba (aléatoire avec probabilité)
<?php
/**
* Tirage aléatoire d'un élément selon des probabilités définies
* Ex :
* // 20% de proba de retourner la valeur x, 15% pour y, etc
* array_rand_proba(array('x' => 20, 'y' => 15, 'z' => 35, 't' => 30
* ))
*
* @param array $proba - Liste de valeurs associées à la probabilité de la tirer
* @return string - Valeur tirée au hasard
@a-mt
a-mt / index.tpl
Created January 23, 2017 15:21
Smarty : Get random item from array
{assign var=images value='/,\s*/'|preg_split:'imga.png, imgb.png, imgc.png'}
{assign var=randomindex value=$images|@array_rand}
<div class="partenaire">
<img src="{$images.$randomindex}" border="0" alt="Image" height="32">
</div>
@a-mt
a-mt / jslint.conf
Created December 24, 2016 18:47 — forked from jashkenas/jslint.conf
#
# Configuration File for JavaScript Lint 0.2.6
# Developed by Matthias Miller (http://www.JavaScriptLint.com)
#
# This configuration file can be used to lint a collection of scripts, or to enable
# or disable warnings for scripts that are linted via the command line.
#
#### NOTE TO TEXTMATE BUNDLE USERS:
#### Feel free to experiment with enabling/disabling individual warnings to
@a-mt
a-mt / index.js
Last active December 18, 2020 04:30 — forked from pibby/JS: Highlight current menu item on fixed nav as user scrolls
JS: Highlight current menu item on fixed nav as user scrolls
// Highlight current page menu item as user scrolls
var lastId,
pageMenu = $(".nav"),
pageMenuHeight = pageMenu.outerHeight() + 126,
// All list items
menuItems = pageMenu.find("a"),
// Anchors corresponding to menu items
scrollItems = menuItems.map(function(){
var item = $($(this).attr("href"));
if (item.length) { return item; }
@a-mt
a-mt / string-utils.js
Created October 30, 2016 11:39 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();