Skip to content

Instantly share code, notes, and snippets.

View mariocesar's full-sized avatar

Mario-César mariocesar

View GitHub Profile
@mariocesar
mariocesar / README.md
Last active November 9, 2023 12:29
Git useful commands

Searching for a text in all the history of the repo.

function grep_git_history() {
  local term="${@}"
  git grep -e "${term}" $(git log -S "${term}" --pretty=format:"%H")
}

grep_git_history 'var = 1'
grep_git_history '{% url'
@mariocesar
mariocesar / README.md
Last active October 7, 2021 21:59
Complete uwsgi Setup for production

How to use

mkdir -p var/run
mkdir -p var/log
mkdir -p public/static
mkdir -p public/media

uwsgi --ini uwsgi.ini
@mariocesar
mariocesar / README.md
Last active May 6, 2019 13:17
Notes about Systemd for webapplications like Django, Flask, Aiohttp

To create the service file.

sudo vim /etc/systemd/system/webapp.service
sudo systemctl daemon-reload
sudo systemctl enable webapp.service
sudo systemctl start webapp
sudo systemctl restart webapp

If your webapp creates a unix socket, you could fix permissions by using a .path unit observer.

@butla
butla / wait_for_tcp_port.py
Last active December 8, 2022 19:52
Waiting for a TCP port to start accepting connections (Python >=3.6)
"""
MIT License
Copyright (c) 2017 Michał Bultrowicz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@m-abs
m-abs / image-cache.pipe.ts
Last active February 26, 2020 21:16
ImageCache pipe for NativeScript-Angular
import { Pipe, PipeTransform, NgZone } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { ImageSource, fromResource } from 'image-source';
import { Cache } from 'ui/image-cache';
import { isFileOrResourcePath, isDataURI } from 'utils/utils';
let cache = new Cache();
cache.placeholder = fromResource('placeholder');
@Brainiarc7
Brainiarc7 / ffmpeg-livestream-to-streaming-sites-vaapi-nvenc.md
Last active April 21, 2024 04:22
ffmpeg livestreaming to youtube via Nvidia's NVENC and Intel's VAAPI on supported hardware

Streaming your Linux desktop to Youtube and Twitch via Nvidia's NVENC and VAAPI:

Considerations to take when live streaming:

The following best practice observations apply when using a hardware-based encoder for live streaming to any platform:

  1. Set the buffer size (-bufsize:v) equal to the target bitrate (-b:v). You want to ensure that you're encoding in CBR mode.

  2. Set up the encoders as shown:

@mariocesar
mariocesar / README.md
Last active July 16, 2021 16:01
Ansible for the frugal

Ansible for the frugal

I got this idea about using deploy scripts in the same way developer use ansible playbooks. I know is far from ideal, but I was able to make it work for my personal use.

So, the basics: Send a directory, execute a script in it, remove the directory when done.

For the future:

  • apt utils
  • service utils
@vkurup
vkurup / generate_factories.py
Last active April 16, 2021 20:03 — forked from tobiasmcnulty/generate_factories.py
Django management command to generate factory-boy boilerplate factory definitions for all the models in a given app. The code is not intended to be usable right off the bat, it just provides a few sane defaults based on the structure of your models.
from django.core.management.base import BaseCommand
from django.db.models import get_models, get_app, fields
from django.db.models.fields import related
class Command(BaseCommand):
help = """Generate factory-boy factories for the given app"""
def handle(self, *args, **options):
assert len(args) == 1, 'Must specify app name as first and only argument'
@hvrauhal
hvrauhal / README.md
Last active May 23, 2022 05:51
Aggressively caching squid for http://registry.npmjs.org/

Caching http://registry.npmjs.org/ aggressively with squid

We run a lot of project in our automated test environment and they spend a lot of time doing npm install. One way to speed up npm install and hammer the registry a little less is to use the http-version of the registry and to pass the requests through a proxy.

However, the npm requests include an authorization-header and the responses come with an ETag and Cache-Control: max-age=60, so with default squid settings there is a lot of roundtrips to registry.npmjs.org that result in 304's.

This is what the requests look like once npm has cached the first set of responses:

GET http://registry.npmjs.org/sntp HTTP/1.1

@Himanshu-Mishr
Himanshu-Mishr / theme
Created May 6, 2015 07:36
126 Themes for Terminal (Elementary OS)
#!/bin/bash
# Download it.
# Name it as 'theme'
# Place it in /usr/bin/
# shell_prompt$ theme
echo '
3024 Day ( 1) 3024 Night ( 2) AdventureTime ( 3)
Afterglow ( 4) AlienBlood ( 5) Argonaut ( 6)
Arthur ( 7) Atom ( 8) Belafonte Day ( 9)
Belafonte Night ( 10) BirdsOfParadise ( 11) Blazer ( 12)