Skip to content

Instantly share code, notes, and snippets.

View antonioj-mattos's full-sized avatar

Antonio Jr. Mattos antonioj-mattos

View GitHub Profile
@antonioj-mattos
antonioj-mattos / Appx-Uninstaller.ps1
Created November 28, 2023 21:53 — forked from ThioJoe/Appx-Uninstaller.ps1
A basic script for uninstalling a list of app packages in Windows 10/11, including those pre-installed with Windows
# A basic script for uninstalling app packages in Windows 10/11, including those pre-installed with Windows
#
# Note: If you get an error about the script not being allowed to run, the below command will change the execution polciy temporarily for one session only:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
#
# To execute the script, open a Powershell window to the directory with the script and run the following command using your scripts file name (and don't forget the .\ )
# .\WhateverScriptName.ps1
# -------------------------------------------------------------------------------------------
# Script by ThioJoe - https://github.com/ThioJoe
@antonioj-mattos
antonioj-mattos / Resources.scala
Created March 11, 2023 03:29 — forked from Slakah/Resources.scala
Macro to read resources at compile time
package fastparse.protobuf
import java.nio.file.{Files, Paths}
import scala.reflect.macros.whitebox
import scala.jdk.CollectionConverters._
object Resources {
def readResource(path: String): String = macro Resources.readResourceImpl
@antonioj-mattos
antonioj-mattos / layered.cs
Last active June 19, 2022 19:47 — forked from ralfw/layered.cs
Layered design vs stratified design
using System;
using System.Linq;
namespace layered
{
class MainClass
{
public static void Main(string[] args) {
var data = new DataLayer();
var business = new BusinessLayer(data);
@antonioj-mattos
antonioj-mattos / bulk_upsert.py
Created May 8, 2022 23:53 — forked from aisayko/bulk_upsert.py
Postgresql bulk upsert in Python (Django)
def bulk_upsert(model, fields, values, by):
"""
Return the tuple of (inserted, updated) ids
"""
result = (None, None)
if values:
stmt = """
WITH data_set AS (
INSERT INTO %s (%s)
@antonioj-mattos
antonioj-mattos / pre-commit
Created December 17, 2020 23:39 — forked from mcls/pre-commit
Regex blacklist for git diff in git pre-commit hook
#!/usr/bin/env python
from subprocess import *
import sys
import re
# Add Regex to blacklist here
blacklist = [
"\+[ ]+NSLog.+" # Prevent NSLog's from being added
]
@antonioj-mattos
antonioj-mattos / secure_link.php
Created October 24, 2020 01:12 — forked from bftanase/secure_link.php
generate URL for nginx secure_link
from django.contrib.admin import ModelAdmin
class MyTableAdmin(ModelAdmin):
...
paginator = LargeTablePaginator
...
@antonioj-mattos
antonioj-mattos / celery.py
Created February 7, 2020 03:06 — forked from tapanpandita/celery.py
Transaction aware celery abstract task
class TransactionAwareTask(Task):
'''
Task class which is aware of django db transactions and only executes tasks
after transaction has been committed
'''
abstract = True
def apply_async(self, *args, **kwargs):
'''
Unlike the default task in celery, this task does not return an async
@antonioj-mattos
antonioj-mattos / celery_tasks_error_handling.py
Created February 5, 2020 21:23 — forked from darklow/celery_tasks_error_handling.py
Celery tasks error handling example
from celery import Task
from celery.task import task
from my_app.models import FailedTask
from django.db import models
@task(base=LogErrorsTask)
def some task():
return result
class LogErrorsTask(Task):
@antonioj-mattos
antonioj-mattos / django_jwt_cookie.py
Created December 3, 2019 18:14 — forked from elnygren/django_jwt_cookie.py
Teach Django to use JWT tokens inside the session cookie - plays well with django-rest-framework-jwt.