Skip to content

Instantly share code, notes, and snippets.

View samirfor's full-sized avatar

Samir C. Costa samirfor

  • Brazil
  • 04:33 (UTC -03:00)
View GitHub Profile
@syukronrm
syukronrm / README.md
Created August 10, 2022 05:32 — forked from nikoheikkila/README.md
Fish Shell function for sourcing standard .env files

envsource

I've been using Fish shell for years which is great and all, but one thing that has got me frustrated is using it with .env files.

When attempting to run source .env in a project, I usually encounter this problem:

.env (line 2): Unsupported use of '='. In fish, please use 'set KEY value'.
from sourcing file .env
source: Error while reading file '.env'
@ramsrib
ramsrib / fields.py
Last active May 2, 2023 22:32 — forked from ambivalentno/svgimagefield.py
A form field to handle validation of image + svg in Django 3
import sys
import xml.etree.cElementTree as et
from io import BytesIO
from django.core.exceptions import ValidationError
from django.core.validators import (
FileExtensionValidator,
get_available_image_extensions,
)
from django.forms import ImageField as DjangoImageField
@kabili207
kabili207 / Rclone systemd service.md
Last active October 29, 2024 20:52
Rclone systemd user service

rclone systemd service

Preparation

This service will use the same remote name you specified when using rclone config create. If you haven't done that yet, do so now.

Next, create the mountpoint for your remote. The service uses the location ~/mnt/<remote> by default.

mkdir ~/mnt/dropbox
@madebyollin
madebyollin / make_audiobook.py
Last active September 17, 2024 12:59
Converts an epub or text file to audiobook via Google Cloud TTS
#!/usr/bin/env python3
"""
To use:
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client
2. install pandoc and pypandoc, also tqdm
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub
"""
import re
import sys
@zamber
zamber / ssh-telegram.sh
Last active November 1, 2019 07:05 — forked from matriphe/ssh-telegram.sh
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use sed to parse JSON from ipinfo.io
# you can get your user_id by writing to @get_id_bot
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ] && [ -z "$TMUX" ]; then
@tzmartin
tzmartin / m3u8-to-mp4.md
Last active November 17, 2024 04:41
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
#!/usr/bin/mongo --quiet
//Load data
print("Loading data..\n");
load('data.js'); //The file from Firebase
//Connect to MongoDB
var db = connect("localhost:27017/MyDatabase");
//Add collections
@bmaupin
bmaupin / install-oracle-java7-centos.md
Last active March 12, 2019 14:24
Install Oracle Java 7 on CentOS
@6farer
6farer / SSL cert generation.sh
Created March 9, 2016 15:40
Generate SSL Certificates
#! /bin/bash
NAME=$1
if [ -z $NAME ]; then
echo "First parameter should be a name for the output files, e.g. devint.company.local"
exit -1
fi
openssl genrsa -out $NAME.key 2048
openssl req -new -key $NAME.key -out $NAME.csr
@sureshnath
sureshnath / regex.email.txt
Created April 10, 2015 09:48
email regex
[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b
https://regex101.com/
/[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b/
[A-Za-z0-9._%-]+ match a single character present in the list below
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
A-Z a single character in the range between A and Z (case sensitive)
a-z a single character in the range between a and z (case sensitive)
0-9 a single character in the range between 0 and 9