Skip to content

Instantly share code, notes, and snippets.

View boogheta's full-sized avatar

Benjamin Ooghe-Tabanou boogheta

View GitHub Profile
let scroll = 0;
function handleNextMedia() {
const el = document.querySelector(".Media");
if (!el) {
document.querySelector(".Profile.custom-scroll").scrollTo(0, scroll + 1800);
return setTimeout(() => handleNextMedia(), 5000);
}
$(el).click();
setTimeout(() => {
$(".MediaViewerActions .icon-download").click();
@boogheta
boogheta / build_gif.sh
Last active August 25, 2022 17:26
Network spatialization with graophology's FA2 on huge networks with PNG exports
convert -delay 5 $1_snapshot_*.png $1.gif
This file has been truncated, but you can view the full file.
<?xml version='1.0' encoding='UTF-8'?>
<gexf xmlns="http://gexf.net/1.3" version="1.3" xmlns:viz="http://gexf.net/1.3/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://gexf.net/1.3 http://gexf.net/1.3/gexf.xsd">
<meta lastmodifieddate="2022-07-08">
<creator>Gephi 0.9.3</creator>
<description></description>
</meta>
<graph defaultedgetype="undirected" mode="static">
<attributes class="node" mode="static">
<attribute id="attr_type" title="attr_type" type="string"/>
@boogheta
boogheta / test_port.py
Created April 21, 2022 12:15
Test port open
#!/usr/bin/env python
import sys
from socket import socket
ports = range(int(sys.argv[1]), int(sys.argv[2]))
s = socket()
for port in ports:
try:
print "TEST %s..." % port
@boogheta
boogheta / scan_ports.sh
Created April 21, 2022 12:12
Scan open ports
alarm() {
perl -e '
eval {
$SIG{ALRM} = sub { die };
alarm shift;
system(@ARGV);
};
if ($@) { exit 1 }
' "$@";
}
#!/usr/bin/env python
import os
import sys
import csv
import json
import requests
metadata = {
"id": None, "desc": None, "createTime": None, "originalItem": None,
@boogheta
boogheta / instagram.py
Created January 14, 2020 15:59
Collect users and followers on Instagram with fake InstagramAPI
import sys, json
from InstagramAPI import InstagramAPI
from time import sleep
from pprint import pprint
#import pandas as pd
#import requests, urllib, bs4, ssl, json, sys, re
def connect_api(user, password):
api = InstagramAPI(user, password)
retries = 12
@boogheta
boogheta / parse_factiva_html.py
Created November 12, 2019 16:20
Factiva's html parser
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys, csv, json
from datetime import datetime
from pyquery import PyQuery as pq
# TODO
# - Remove duplicates
# - Filtering
@boogheta
boogheta / assemble.sh
Created March 22, 2018 10:41
Assemble csv lycées
# On lit les headers dans la première ligne des csv
headers=$(cat */*/*.csv | head -1)
# On réécrit les headers avec nos champs en plus dans le fichier final
echo "Lycee,classe,eleve,$headers" > all.csv
# On itère sur l'arborescence des dossiers et stocker les noms dans des variables
ls | grep Lycée | while read lycee; do
ls "$lycee" | while read classe; do
ls "$lycee/$classe" | grep ".csv$" | sed 's/\.csv$//' | while read eleve; do
@boogheta
boogheta / ratio_similarity.md
Created April 11, 2017 09:44
Calcul de ratio de similarité entre 2 textes avec difflib en python.md
from difflib import SequenceMatcher
text1 = "Mais pourquoi la petite sirène est-elle aussi super, ce n'est pas comme les méchants poissons"
text2 = "Il était une fois une petite sirène super méchante qui mangeait des poissons"
matcher = SequenceMatcher(None, text1, text2)
blocks = matcher.get_matching_blocks()
for pos1, pos2, size in blocks:
    print(size, pos1, pos2, text1[pos1:pos1+size])
>>> 1 1 5 a
&gt;&gt;&gt; 3 2 15 is