Skip to content

Instantly share code, notes, and snippets.

@gsscoder
gsscoder / random_art.hs
Last active December 30, 2019 16:12
Haskell port of F# http://fssnip.net/si
{-|
Haskell port of F# http://fssnip.net/si
-}
import Control.Applicative ((<$>), (<*>))
import System.Random (randomIO, randomRIO)
import qualified Data.ByteString.Lazy as B
import Data.Word8
data Expr =
VariableX
@gsscoder
gsscoder / tga.hs
Created September 21, 2015 16:45
Haskell port of OCaml http://pastebin.com/a66MDZkP
{-|
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 ()
@gsscoder
gsscoder / pyenv-install-python-380.log
Created November 2, 2019 05:39
Pyenv debug output installing python 3.8.0
+ [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 '' ']'
@gsscoder
gsscoder / csv2regex_lang-codes.py
Last active November 9, 2019 09:05
Script to turn languages code into part of a regex
# 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 / names.json
Last active November 16, 2025 21:08
List of names in JSON format
[
"Liam",
"Noah",
"William",
"James",
"Logan",
"Benjamin",
"Mason",
"Elijah",
"Oliver",
@gsscoder
gsscoder / scrap-fb.py
Last active November 23, 2019 05:23
Script that scrapes Facebook demonstrating facebook_snooper
"""
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 [email protected] your_password
Note:
@gsscoder
gsscoder / csv2json_cities.py
Last active November 16, 2019 06:47
Creates a list of cities in JSON
# 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 / check-term-colors.py
Last active November 16, 2019 06:47
Checks if terminal supports colors
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 / myprofile.sh
Last active November 16, 2019 10:59
Shell customizations
# 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 / jsonify.py
Last active November 21, 2019 13:49
Turns a javascript dictionary into a JSON string
# 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: