Skip to content

Instantly share code, notes, and snippets.

Giacomo Stelluti Scala gsscoder

Block or report user

Report or block gsscoder

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gsscoder
gsscoder / fbscrap_5random.py
Created Nov 21, 2019
Scrapes facebook for 5 random persons in 5 random cities
View fbscrap_5random.py
"""
fbscrap_cities.py:
Demonstrates facebook_snooper package (https://github.com/gsscoder/facebook-snooper/).
For version: 0.3.5
Usage: python3 fbscrap_5random
"""
from facebook_snooper import Session
import requests
import json
@gsscoder
gsscoder / jsonify.py
Last active Nov 21, 2019
Turns a javascript dictionary into a JSON string
View jsonify.py
# jsonify('{ hello: "json", hello_again: { from: ["java", "script"]}}')
# '{ "hello": "json", "hello_again": { "from": ["java", "script"]}}'
# note: before calling better use https://github.com/beautify-web/js-beautify
def jsonify(js_dict_code):
json_string = js_dict_code
matches = re.findall(r'(?<![\S"])([^"\s{}\[\],]+:)(?![\S"])', js_dict_code)
if matches:
for unquoted in matches:
@gsscoder
gsscoder / myprofile.sh
Last active Nov 16, 2019
Shell customizations
View myprofile.sh
# common aliases
alias ll='ls -lha'
alias la='ls -A'
alias l='ls -CF'
# grep options
export GREP_OPTIONS="--color=always"
export GREP_COLOR="1;35;40"
# editor
@gsscoder
gsscoder / check-term-colors.py
Last active Nov 16, 2019
Checks if terminal supports colors
View check-term-colors.py
def supports_color():
# Ripped from: https://github.com/django/django/blob/master/django/core/management/color.py#L12
plat = sys.platform
supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ)
# isatty is not always implemented, #6223.
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
return supported_platform and is_a_tty
@gsscoder
gsscoder / csv2json_cities.py
Last active Nov 16, 2019
Creates a list of cities in JSON
View csv2json_cities.py
# file URL: https://raw.githubusercontent.com/gsscoder/test-data/master/largest-cities.csv
import csv
import re
cities = []
with open('largest-cities.csv') as f:
reader = csv.DictReader(f, delimiter=',')
for row in reader:
@gsscoder
gsscoder / scrap-fb.py
Last active Nov 21, 2019
Script that scrapes facebook demonstrating facebook_snooper
View scrap-fb.py
"""
scrap-fb.py:
Demonstrates facebook_snooper module (https://github.com/gsscoder/facebook-snooper).
Install requirements:
$ wget https://raw.githubusercontent.com/gsscoder/facebook-snooper/master/facebook_snooper.py
$ wget https://raw.githubusercontent.com/gsscoder/facebook-snooper/master/requirements.txt
$ python3 -m pip install -r requirements.txt
Run:
$ python3 scrap-fb.py your@login.fb your_password
Note:
@gsscoder
gsscoder / names.json
Last active Nov 7, 2019
List of names in JSON format
View names.json
[
"Liam",
"Noah",
"William",
"James",
"Logan",
"Benjamin",
"Mason",
"Elijah",
"Oliver",
@gsscoder
gsscoder / csv2regex_lang-codes.py
Last active Nov 9, 2019
Script to turn languages code into part of a regex
View csv2regex_lang-codes.py
# file URL: https://raw.githubusercontent.com/gsscoder/test-data/master/language-codes-3b2.csv
buf = ''
with open('language-codes-3b2.csv') as csv:
data = csv.readlines()
for d in data[1:]:
langs = d.split(',')
buf += f'{langs[0].upper()}|{langs[1].upper()}|'
@gsscoder
gsscoder / pyenv-install-python-380.log
Created Nov 2, 2019
Pyenv debug output installing python 3.8.0
View pyenv-install-python-380.log
+ [pyenv:22] enable -f /usr/local/bin/../libexec/pyenv-realpath.dylib realpath
+ [pyenv:29] '[' -z '' ']'
++ [pyenv:31] type -p greadlink readlink
++ [pyenv:31] head -1
+ [pyenv:31] READLINK=/usr/bin/readlink
+ [pyenv:32] '[' -n /usr/bin/readlink ']'
+ [pyenv:57] '[' -z /Users/giacomo/.pyenv ']'
+ [pyenv:60] PYENV_ROOT=/Users/giacomo/.pyenv
+ [pyenv:62] export PYENV_ROOT
+ [pyenv:65] '[' -z '' ']'
View tga.hs
{-|
Haskell port of OCaml http://pastebin.com/a66MDZkP
-}
import qualified Data.ByteString.Lazy as B
import Data.Word8
type Point = (Double, Double)
type Rgb = (Double, Double, Double)
tga :: (Point -> Rgb) -> Int -> Int -> String -> IO ()
You can’t perform that action at this time.