This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import FileResponse | |
from io import BufferedReader, BytesIO | |
def file_response_from_str(content: str, filename: str) -> FileResponse: | |
""" Serves a file response from the given string | |
Args: | |
content: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fibonacci: | |
def __init__(self, first: int = 1): | |
self.curr = 1 | |
self.last = 0 | |
while self.value < first: | |
self.__next__() | |
@property | |
def value(self) -> int: | |
return self.curr + self.last |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun isPalindrome(x: Int): Boolean | |
{ | |
if (x < 0) return false | |
val x = x.toString() | |
var left = 0; | |
var right = x.length - 1; | |
while (left < right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Salvar num arquivo ~/encode.sh, conceder direito de execução e | |
# executar desta forma (adaptar nomes de diretórios e arquivos para seu caso): | |
# $ ~/encode.sh ~/Video/bigFile.mp4 ~/Video/smallFile.mp4 | |
ffmpeg -i "$1" -vcodec h264 -acodec aac "$2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document | |
.querySelectorAll('button[aria-label^="Aceitar o convite de"]') | |
.forEach((btn, i) => setTimeout(() => btn.click(), i + 500)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# first step, configure your locale | |
sudo dpkg-reconfigure locales | |
# on the screen scroll down and choose pt_BR.UTF8 | |
# then next you will do ok and ok, and run this on the command line | |
sudo update-locale LANG=pt_BR.UTF8 | |
# in the end you run this | |
setxkbmap -model abnt2 -layout br -variant abnt2 | |
# and don't restart WSL yet, just try... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
-- table_name, | |
-- pg_size_pretty( pg_total_relation_size(quote_ident(table_name))), | |
-- pg_size_pretty(sum(pg_total_relation_size(quote_ident(table_name)))) | |
pg_size_pretty(sum(pg_total_relation_size(quote_ident(table_name)))) | |
from information_schema.tables | |
where | |
table_schema = 'public' | |
-- order by pg_total_relation_size(quote_ident(table_name)) desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int dividendo; | |
int divisor; | |
int resultado = 0; | |
int resto = 0; | |
printf("Dividendo: "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function () { | |
'use strict'; | |
$.plugins = $.plugins || {}; | |
$.plugins.confirm = function () { | |
// ----------------------------------------------------------------------------------- | |
// possibilidades de uso: | |
// | |
// 1 -> mensagem 'mensagem' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ask for the user password | |
# Script only works if sudo caches the password for a few minutes | |
sudo true | |
# Install kernel extra's to enable docker aufs support | |
# sudo apt-get -y install linux-image-extra-$(uname -r) | |
# Add Docker PPA and install latest version | |
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" |
NewerOlder