Skip to content

Instantly share code, notes, and snippets.

View douglaspetrin's full-sized avatar

Douglas Petrin Bertini douglaspetrin

View GitHub Profile
@douglaspetrin
douglaspetrin / mysql-commands.md
Created October 12, 2019 13:52
MySQL Commands

Dump (Backup DATABSE)

mysqldump --opt --user=username --password=password --host=yourMySQLHostname dbname > nameofyourbackup.sql

@douglaspetrin
douglaspetrin / Python_Json_Overview.md
Last active October 8, 2019 17:53
Python JSON Encoder & Decoder Overview

JSON Overview

Json is a lightweight data interchange format and its module always produces string objects, not bytes objects. That said, you can serialize or deserialize data. But.. What is data serialization?

Data serialization

Data serialization is the process of converting structure data to a format that allows sharing or storage of data in a way that it is possible to recover its original format.

Why serialize data?

@douglaspetrin
douglaspetrin / .gitignore
Created October 2, 2019 14:08
.gitignore model for other projects
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
@douglaspetrin
douglaspetrin / doug2.theme.sh
Last active October 1, 2019 00:45
dougTheme2 - bash version
#!/usr/bin/env bash
#
# One line prompt showing the following configurable information
# for git:
# time (virtual_env) username@hostname pwd git_char|git_branch git_dirty_status|→
#
# The → arrow shows the exit status of the last command:
# - bold green: 0 exit status
# - bold red: non-zero exit status
#
@douglaspetrin
douglaspetrin / redis-commands
Last active September 30, 2019 20:38
redis-commands
----------------------------
# Overview of redis commands
----------------------------
SET server:name "fido"
GET server:name => "fido"
SET connections 10
@douglaspetrin
douglaspetrin / dougTheme.sh
Created September 16, 2019 22:33
bash | dougTheme
# Doug Bash Prompt
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
fi
if tput setaf 1 &> /dev/null; then
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
@douglaspetrin
douglaspetrin / starpy_cli_usage_example
Last active July 23, 2019 15:07
StarPy | CLI Usage Example
$ python start.py find-fastest-s
# Returns the fastest starships
$ python start.py vehicles-speed-by-person 1
# Returns Luke's vehicles and its max. speed
@douglaspetrin
douglaspetrin / starpy_example.py
Last active July 23, 2019 15:01
StarPy | Example of usage
import starpy
# Instance of the object
s = starpy.GetStars()
s.find_fastest_s()
# this method finds the fastest StarShips
s.vehicles_speed_by_person(1)
# this method gets the vehicles and its speed by passing a person's id as argument
@douglaspetrin
douglaspetrin / starpy_basic_usage.py
Created July 22, 2019 00:34
StarPy | Basic Usage
import starpy
# Instance of the object
s = starpy.GetStars()
s.starships_speed_by_person(11)
# Returns: [[{'transport_id': '59', 'Max. Speed': '1050'}],
# [{'transport_id': '65', 'Max. Speed': '1500'}],
# [{'transport_id': '39', 'Max. Speed': '1100'}]]
class Gist(object):
def __init__(self):
self.name = 'Douglas'
def read_name(self):
return self.name