Skip to content

Instantly share code, notes, and snippets.

@mems
mems / dabblet.css
Last active August 29, 2015 14:01
`background-attachment: local` on div, textarea and iframe
textarea, div, iframe{
width: 300px;
height: 200px;
background: url("https://developer.mozilla.org/samples/cssref/images/cartooncat.png") local;
overflow: auto;
}
<p>Submit programmatically not work correctly. Some browsers send directly the form without trigger submit event and/or execute validation.</p>
<p>Submit the form! If the field is empty, you should see the native validation display an error message (for browsers that support HTML5 form validation). Then a confirm dialog box should ask you if you want to search the given term on Google Search</p>
<form id="form" action="http://google.com" target="_parent">
<p><label for="term">Search on Google:</label> <input type="text" name="q" id="term" value="" required></p>
<fieldset>
<legend>Programmatically form submition</legend>
<p><label for="method">Method:</label> <select id="method">
<option value="method">form.submit()</option>
<option value="event">Trigger submit event</option>
@mems
mems / config.xml
Created September 22, 2014 11:39
JavaScript HTML injection for Intellij
<?xml version="1.0" encoding="UTF-8"?>
<LanguageInjectionConfiguration>
<injection language="HTML" injector-id="js">
<display-name>&quot;&lt;html&gt;&quot;</display-name>
<place><![CDATA[jsLiteralExpression().withText(string().matchesBrics("(\\<\\<\\<)?.*\\</?<anyname>.*>.*"))]]></place>
</injection>
</LanguageInjectionConfiguration>
@mems
mems / har2maff.py
Last active August 29, 2015 14:17 — forked from mdaniel/har2maff.py
Convert HAR to MAFF
#! /usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
from bs4 import BeautifulSoup
import hashlib
import logging
import json
import os
import sys
import re
@mems
mems / gist:5169578
Created March 15, 2013 12:33
Function to handle binayr string to write short, long, and array of shorts and longs
<?php
/**
* Decode a binary string (2 bytes only) to a short
* @param $input binary string to decode
* @return short decoded
*/
function str2short($data)
{
//*<- add or remove "/" to toggle comment
@mems
mems / gist:5338017
Last active December 15, 2015 23:09
Add support of load an image in http://www.rw-designer.com/online-cursor-editor tool (Make CUR file)
/*
Make CUR file using online editor, with basic support of load an image
http://www.rw-designer.com/online-cursor-editor
Require image file to base64 string convertion tool like:
http://www.motobit.com/util/base64-decoder-encoder.asp
*/
//------------
@mems
mems / jquery.img-rend.js
Created May 23, 2013 15:32
Image rendering jQuery CSS hook
/**
* Image rendering jQuery CSS hook
* Usage:
* element.css("image-rendering", "crisp-edges");
* element.css("image-rendering", "auto");
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
*/
(function($) {
if ( !$.cssHooks ) {
throw("jQuery 1.4.3+ is needed for this plugin to work");
@mems
mems / README.md
Created March 27, 2016 17:40
Download all videos from http://www.appanimations.com/

First exec this in WebDev console for each page, copy in clipboard the iframes src of each videos + title + keywords

copy(JSON.stringify(Array.from(document.querySelectorAll("article")).map(article => [article.querySelector("iframe").src, /<a[^>]*>([^<]+)/.exec(article.querySelector("textarea").value)[1], article.querySelector(".cat").textContent])))

Go to https://videos.sproutvideo.com/embed/189bdbb01e1ce7c790/98b77e706be88310, open WebDev console and exec:

var videos = [
@mems
mems / performance.html
Last active March 29, 2016 17:14
Canvas stress test. Usefull for detect low-end devices or old tablets/smartphones
<!DOCTYPE html PUBLIC>
<html>
<head>
<title></title>
</head>
<body>
<script>
// Polyfill
window.performance = (window.performance || {
offset: Date.now(),
@mems
mems / README.md
Created October 6, 2016 20:27
Convert Thunderbird mbox to maildir

Email file name is the timestamp of received email (in microseconds). Example: 1466698612265640, start with From - Thu Jun 23 18:16:52 2016 (Thu Jun 23 2016 18:16:52 GMT+0200 (CEST))

Use NodeJS:

// Note: this script not work properly if an email contains "\n\nFrom - "
const fs = require('fs');
const path = require('path');