Skip to content

Instantly share code, notes, and snippets.

View VivienGiraud's full-sized avatar
🏒
Freelancing

Vivien Giraud VivienGiraud

🏒
Freelancing
View GitHub Profile
@VivienGiraud
VivienGiraud / countries.json
Last active August 31, 2018 13:07 — forked from r1ckhenry/countries.json
countries json with currencies list
[
{
"name": "Afghanistan",
"topLevelDomain": [
".af"
],
"alpha2Code": "AF",
"alpha3Code": "AFG",
"callingCodes": [
"93"
@VivienGiraud
VivienGiraud / useful_code_in_python.py
Last active September 13, 2021 16:33
Add timing decorator
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def flag(code):
OFFSET = ord('🇦') - ord('A')
return chr(ord(code[0]) + OFFSET) + chr(ord(code[1]) + OFFSET)
print(flag('FR'))
🇫🇷
@VivienGiraud
VivienGiraud / free_sms_notifications.py
Created May 31, 2018 10:10
Petit script permettant de notifier votre téléphone (réseau Free) d'un sms !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from sys import exit, argv
from os import environ
try:
import requests
except Exception as e:
print("Need to install requests -> pip3 install requests")
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
function get_key(siren) {
if (siren.length != 9) {
return null;
} else {
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from gremlin_python import statics
from gremlin_python.process.graph_traversal import __
LOOP_LENGTH = 3
if __name__ == '__main__':
@VivienGiraud
VivienGiraud / useful_cmd.md
Last active December 29, 2018 00:29
Useful cmd

OSX

  • Recursively Remove .DS_Store Files on Mac OS X
    find . -name ‘*.DS_Store’ -type f -delete  
  • Generate random mac address and set it
    sudo ifconfig en0 ether $(perl -e 'for ($i=0;$i<5;$i++){@m[$i]=int(rand(256));} printf "02:%X:%X:%X:%X:%X\n",@m;') && sudo ifconfig en0 down && sudo ifconfig en0 up
  • Get list of huge files
    mdfind 'kMDItemFSSize>=1e8&&kMDItemContentTypeTree!=public.directory' | while IFS= read -r l; do stat -f'%z %N' "$l"; done | sort -rn  

AWS  

S3

  • Sync folder with public read right (perfect for a website)
@VivienGiraud
VivienGiraud / get_random_header.py
Created November 29, 2017 10:22
[PYTHON] Returns randomly a user agent in list
USER_AGENT_LIST = [
{'User-agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'},
{'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1'},
{'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/28.0.1469.0 Safari/537.36'},
{'User-agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/28.0.1469.0 Safari/537.36'},
{'User-agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36'},
{'User-agent': 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36'},
{'User-agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36'},
{'User-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Sa
@VivienGiraud
VivienGiraud / Lat_Long.py
Created July 18, 2017 09:40
Lat_Long class for Python 3 (WiP)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
import re
import pyproj
import warnings
import abc
"""
@VivienGiraud
VivienGiraud / Swift 3 - Dijkstra.swift
Created October 27, 2016 09:39 — forked from pocketkk/Swift - Dijkstra.swift
Swift 3 - Shortest Path Algorithm (Compiled from: http://waynewbishop.com/swift/graphs/dijkstra/)
import UIKit
public class Vertex {
var key: String?
var neighbors: Array<Edge>
init() {
self.neighbors = Array<Edge>()
}
}
@VivienGiraud
VivienGiraud / table_generator.py
Last active August 29, 2015 13:56
Create a table of every possibility you want.
#!/usr/bin/python
import itertools
alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s'\
,'t','u','v','w','x','y','z']
maxStringLength = 3
file=open("data.txt",'w');
for x in range (1, maxStringLength + 1):
for i in itertools.product(alphabet,repeat=x):