Skip to content

Instantly share code, notes, and snippets.

View tpatel's full-sized avatar

Thibaut Patel tpatel

View GitHub Profile
@tpatel
tpatel / GetImgUrls.js
Last active December 19, 2015 02:38
Get the list of image urls from a photo page on Facebook.
var a=document.getElementsByClassName('uiMediaThumb'); //get all the photo thumbnails
var s='';
for(var i=0; i<a.length; i++) {
var re = /.*src=(.*.jpg).*/.exec(a[i]); //Extract the url of the full size image
var url = decodeURIComponent(re[1]);
s += url + '\n';
}
console.log(s); //display the list of image url
@tpatel
tpatel / CppTester.cpp
Created September 26, 2013 13:56
CppTester, the simplest test suite.
/**
CppTester, the simplest test suite
*/
#include <iostream>
#include <vector>
struct Test;
std::vector<Test*> tests;
struct Test {
@tpatel
tpatel / fav_meatspaces.js
Created October 26, 2013 02:12
Run this in http://chat.meatspac.es to be able to favorite the best images. The images are stored on your browser. Click on one image to add it to your favorites, click on "X" next to the image to remove it, click on the image to have a bigger view.
(function() {
/*
Run this in http://chat.meatspac.es to be able to favorite the best images. The images are stored on your browser.
Click on one image to add it to your favorites, click on "X" next to the image to remove it, click on the image to have a bigger view.
Made by @thibpat (github.com/tpatel)
*/
function supports_html5_storage() {
try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch (e) {
@tpatel
tpatel / index.html
Last active June 18, 2020 13:54
Basic html5 template
<!DOCTYPE >
<html>
<head>
<meta name="charset" content="utf-8" charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="" />
<title></title>
<link
@tpatel
tpatel / index.js
Last active August 29, 2015 14:04
Generate random hexadecimal token
var r = require('crypto').randomBytes,
punctuation = '-_!:;,?./*=',
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
p = function(t) {
return t[Math.floor(t.length*Math.random())];
},
res = p(punctuation)+p(uppercase)+r(16).toString('hex');
console.log(res);
@tpatel
tpatel / databricksNotifications.js
Created February 16, 2016 16:56
Notify the progress of Databricks Spark notebook computations via web notifications
(function() {
if(!("Notification" in window)) {
return;
}
function notify(str) {
if (Notification.permission === "granted") {
new Notification(str);
}
}
@tpatel
tpatel / readme.md
Created June 7, 2016 07:52
Convert a video to a gif
rm -rf /tmp/gif
mplayer -ao null <video file name> -vo jpeg:outdir=/tmp/gif
convert /tmp/gif/* /tmp/gif/output-temp.gif
convert /tmp/gif/output.gif -fuzz 5% -layers Optimize /tmp/gif/output-temp.gif
<!DOCTYPE>
<html>
<head>
<meta name="charset" content="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="//cdnjs.cloudflare.com/ajax/libs/normalize/6.0.0/normalize.min.css" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,700" rel="stylesheet" type="text/css">
<style>
html {
var elems = [].slice.call(document.querySelectorAll('.js-issue.ghx-selected'));
var total = 0;
var count = 0;
elems.forEach(function(elem) {
var points = parseFloat(elem.querySelector('*[title="Story Points"]').innerText);
total += points;
count++;
})
alert(total + ' points\n' + count + ' tickets');
@tpatel
tpatel / run-node.sh
Created January 3, 2019 15:37
Run node on a setup without node \o/
docker run -p 3000:3000 -v $(pwd):/src -w /src node:10-alpine node main.js