Skip to content

Instantly share code, notes, and snippets.

View Pythalex's full-sized avatar

Pythalex

View GitHub Profile
@Pythalex
Pythalex / Request.java
Created December 9, 2018 15:24
"Low" level HTTP request with java
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class Request {
@Pythalex
Pythalex / blink.css
Created January 18, 2019 16:34
Comment faire clignoter un élément en CSS avec animation et blink
@Pythalex
Pythalex / sleep.js
Created February 22, 2019 15:35
sleep in js
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
@Pythalex
Pythalex / fold.js
Last active February 22, 2019 15:41
Fold and unfold a section in js
async function fold_switch(id){
let section = jQuery("#" + id);
let visibility = section.css("visibility");
if (visibility === "hidden"){
unfold(section);
} else {
fold(section);
}
}
@Pythalex
Pythalex / pickle_ex.py
Created February 24, 2019 18:04
How to pickle and unpickle (serialize / unserialize) in python
import pickle
class A:
def __init__(self, item):
self.item = item
b = 5
if __name__ == "__main__":
sudo mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xmlout
sudo apt install imagemagick
convert *.jpg result.pdf
python -m cProfile -s cumtime script_a_analyser.py
import json
def encode(dic):
# Marche aussi avec des listes, des listes et dictionnaires imbriqués, etc ...
return json.dumps(dic)
def encode_pretty(dic):
return json.dumps(dic, sort_keys=True, indent=4, separators=(',', ': '))
def encode_compact(dic):
import org.json.*;
public class App
{
public static void main( String[] args )
{
JSONObject jo = new JSONObject();
jo.put("name", "jon doe");
jo.put("age", "22");
jo.put("city", "chicago");
import java.util.ArrayList;
import java.util.List;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**