Skip to content

Instantly share code, notes, and snippets.

View stevensdotb's full-sized avatar
:octocat:
Working from home

Richard Brito stevensdotb

:octocat:
Working from home
  • Spain
View GitHub Profile
@stevensdotb
stevensdotb / linux_header_fixer.sh
Created September 17, 2024 23:15
Fix: Linux header error
# Check current dkms with `sudo dkms status`
sudo dkms uninstall <current_dkms>
sudo apt purge <current_dkms>
sudo apt remove dkms
sudo apt --fix-broken install
sudo apt autoremove
sudo apt update
sudo apt upgrade
@stevensdotb
stevensdotb / long_string_split.py
Last active November 10, 2023 11:27
Long String Split
def split_sring(*, string: str, max_chunk_length: int):
"""Split a string, preferible a long one into a list of chunks
parameters:
string -> String to be splited
max_chunk_length -> Chunks length
"""
chunks = []
from_char = 0
to_char = max_chunk_length
@stevensdotb
stevensdotb / cloudSettings
Last active December 29, 2020 09:20
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-12-29T09:20:40.891Z","extensionVersion":"v3.4.3"}

class has no 'objects' member

Install Django pylint: pip install pylint-djang

Go to: ctrl+shift+p > Preferences: Configure Language Specific Settings > Python

The settings.json available for python language should look like the below:

/**
* Avoid non-numeric characters on input text
*/
numberOnly(event) {
const value = event.target.value;
const lastChar = value.length > 0 ? Number(value[value.length - 1]) : 0 ;
const isNaN = char => char !== char;
if ( isNaN(lastChar) ) {
return false;
}
#!/usr/bin/env bash
###########################################
# Author: Stevens Brito
# Github: stevensdotb
###########################################
# Show usage help
function usage() {
echo "Usage: $(basename $0) [option [argument]] [runserver|runsslserver]" >&2
#!/usr/bin/env bash
###########################################
# Author: Stevens Brito
# Github: stevensdotb
###########################################
# Set environment variables
export FLASK_CONFIG="development"
export FLASK_DEBUG="True"
"""
Removes all files with a given extension
in the directory specified in the path.
Arguments in command line:
path: Path directory of the files
ext: The extension of the files
"""
@stevensdotb
stevensdotb / files_counter.py
Last active July 13, 2018 06:16
Files counter
"""
Counts all files with a given extension in the directory
specified in the path.
Arguments in command line:
path: Path directory of the files
ext: The extension of the files
"""
import os
@stevensdotb
stevensdotb / ipaddr_validator.py
Last active July 13, 2018 05:57
IP Address validator
import re
def validate(ip):
is_valid = True
split_ip = str(ip).split('.')
# 4 numbers separated by dots
if len(split_ip) == 4:
for number in split_ip: