Skip to content

Instantly share code, notes, and snippets.

View karlcow's full-sized avatar
⛩️
Working from … anywhere

Karl Dubost karlcow

⛩️
Working from … anywhere
View GitHub Profile

Safari iOS Request

Host: na.finalfantasyxiv.com
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
Accept-Language: fr-fr
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.3 Mobile/14E277 Safari/603.1.30
Cookie: _ga=GA1.2.1480447581.1502240550; _gat=1; _gat_anotherTracker=1; _gid=GA1.2.1718704641.1502240550; ldst_sess=33b25094105b35baeb93a5418090fb06bdad98f7; ldst_is_support_browser=1; ldst_touchstone=1
@karlcow
karlcow / faster_dict.md
Created June 8, 2017 05:59
dict and optimizations

It is faster to create the dict with the first value than creating and adding.

python -mtimeit "issue = {}; issue['action'] = 'opened'; issue['title'] = 'foo'"
10000000 loops, best of 3: 0.135 usec per loop

python -mtimeit "issue = {'action': 'opened'}; issue['title'] = 'foo'" 
10000000 loops, best of 3: 0.111 usec per loop
@karlcow
karlcow / 001-regex.py
Last active June 5, 2017 01:25
Trying different methods for extracting information
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import urlparse
import re
import sys
# done some commits on last version of master by mistakes
# and some modifications still not committed
git stash
git branch my_new_branch
git reset --hard origin/master
git checkout my_new_branch
git stash pop
# I'm now on my new branch as I should have been
import json
RESULTS = '''
new format: {new}
old format: {old} # can't conclude anything
---------------------
INVALID: On {invalid} > empty: {empty_invalid}
VALID: On {valid} > empty: {empty_valid}
'''
@karlcow
karlcow / google-search.js
Created September 15, 2016 07:51
The only reason why Google Search for Chrome fails on Gecko
(function() {
(function() {
if (!google.xjsir)
if (google.q && google.q.iere) {
for (var d = document.querySelectorAll("#topstuff,#fc,.ichpcnt,#fsad"), a = 0; a < d.length; a++) d[a].classList.add("qs-css-m");
var c = document.getElementById("rg");
c ? (c.style.webkitAnimationDelay = "150ms", c.classList.add("qs-css-m"), c.addEventListener("webkitAnimationEnd", function() {
c.style.webkitAnimationDelay = "";
document.documentElement.classList.remove("qs-css-a");
if (google.isr && google.isr.layout && google.isr.layout.getResultsForPage) {
# Testing Images optimization
# for https://github.com/webcompat/webcompat.com/issues/1051
import os
import shutil
import time
from PIL import Image
IMAGE_PATH = '/Users/karl/Documents/2016/05/webc/original.png'
IMAGE_DEST = '/Users/karl/Documents/2016/05/webc/saved'
<div id="attachment_37654" style="width: 360px" class="wp-caption alignright">
<a href="http://i2.wp.com/www.brixtonblog.com/wp-content/uploads/2016/05/stolen-bike_brixton_650.jpg" target="_blank">
<img class="wp-image-37654"
src="http://i2.wp.com/www.brixtonblog.com/wp-content/uploads/2016/05/stolen-bike_brixton_650.jpg?resize=350%2C420"
alt="Stolen Bike Twitter post for a bike stolen in Brixton"
srcset="
http://i2.wp.com/www.brixtonblog.com/wp-content/uploads/2016/05/stolen-bike_brixton_650.jpg?resize=508%2C610 508w,
http://i2.wp.com/www.brixtonblog.com/wp-content/uploads/2016/05/stolen-bike_brixton_650.jpg?resize=250%2C300 250w,
http://i2.wp.com/www.brixtonblog.com/wp-content/uploads/2016/05/stolen-bike_brixton_650.jpg?w=650 650w"
sizes="(max-width: 350px) 100vw, 350px"
@karlcow
karlcow / amazon-prefetch.js
Created April 19, 2016 00:48
Amazon is targetting Firefox with a bad technique https://bugzilla.mozilla.org/show_bug.cgi?id=1172205 Mozilla fixed a bug but as of today Amazon didn't change yet their script.
amznJQ.available("jQuery", function() {
jQuery(window).load(function() {
setTimeout(function() {
var imageAssets = new Array();
var jsCssAssets = new Array();
imageAssets.push("https://images-fe.ssl-images-amazon.com/images/G/09/x-locale/common/buy-buttons/review-1-click-order._CB171143523_.gif");
imageAssets.push("https://images-fe.ssl-images-amazon.com/images/G/09/x-locale/common/buttons/continue-shopping._CB192262037_.gif");
imageAssets.push("https://images-fe.ssl-images-amazon.com/images/G/09/x-locale/common/buy-buttons/thank-you-elbow._CB192261665_.gif");
imageAssets.push("https://images-fe.ssl-images-amazon.com/images/G/09/x-locale/communities/social/snwicons_v2._CB383421867_.png");
imageAssets.push("https://images-fe.ssl-images-amazon.com/images/G/09/checkout/assets/carrot._CB192555707_.gif");
<updated>2015-09-30T17:46:09+02:00</updated>
<updated>2015-09-30T17:46:11+02:00</updated>
<updated>2015-09-30T17:46:12+02:00</updated>
<updated>2015-09-30T17:46:14+02:00</updated>
<updated>2015-09-30T17:46:16+02:00</updated>
<updated>2015-09-30T17:46:18+02:00</updated>
<updated>2015-09-30T18:06:10+02:00</updated>
<updated>2015-09-30T18:16:03+02:00</updated>
<updated>2015-09-30T18:56:08+02:00</updated>
<updated>2015-09-30T19:16:04+02:00</updated>