Skip to content

Instantly share code, notes, and snippets.

View zodman's full-sized avatar
🤗
Code wins arguments!

Andres Vargas zodman

🤗
Code wins arguments!
View GitHub Profile
@zodman
zodman / server.js
Created February 6, 2025 18:30 — forked from dlukes/server.js
Pattern for using Promise-based background jobs in Node + Express.
/* A quick reminder on how to use Promises with Node and Express in order to run potentially
* time-consuming jobs asynchronously (assuming the jobs are able to run in the background thanks to
* libuv and actually return Promises).
*
* Start the server, navigate to /startjob, then refresh a few times, the job should be in progress.
* You can navigate elsewhere in the "app" in other browser tabs in the meanwhile (/). After about
* 20s, you should get a result by refreshing the tab where you originally submitted the job.
*
* I hope this pattern will be useful e.g. for processing images with the `sharp` library (see
* <http://sharp.dimens.io>).
@zodman
zodman / __init__.py
Created October 16, 2011 06:17
tryton admin jsonrpc
from jsonrpclib import Server as ServerProxy
import base64
import jsonrpclib
import json
class AdminTrytonException(Exception):
def __init__(self, result):
self.result = result
/* eslint-disable @typescript-eslint/ban-types */
// @ts-nocheck
/**
* Use to patch all functions/methods in a class and make them print out run time
* in ms to the console.
*
* This decorator will only patch functions declared in the target class.
* It will **not** patch functions reside in the **base class**.
* Dynamically created functions or functions received from the outside as input
@zodman
zodman / bluetooth.ps1
Last active March 19, 2024 09:57
Enable and disable bluetooth windows by powershell cli ! usefull to sync you airphones
[CmdletBinding()] Param (
[Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$BluetoothStatus
)
If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv }
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
@zodman
zodman / nyaa_fansub.py
Created November 21, 2015 06:10
Get all torrents for a fansub with titles
#!/bin/env python
from nyaa import nyaa
import guessit
import click
@click.command()
@click.argument("nyaa_user")
@click.option("--num_page", default=10, help="Numero de paginas rss a obtener")
def fetch_nyaa_user(nyaa_user, num_page):
""" obtiene de nyaa (rss) todos las series y hace batchs de torrents """
@zodman
zodman / Steps to Obtain Client Secret.md
Created October 4, 2018 00:27 — forked from darthShadow/Steps to Obtain Client Secret.md
Mega Account Creator. Handles registration using megareg. Handles verification using Google Client API.
  1. Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
  2. On the Add credentials to your project page, click the Cancel button.
  3. At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name (Mega Account Creator) if not already set, and click the Save button.
  4. Select the Credentials tab, click the Create credentials button and select OAuth client ID.
  5. Select the application type Other, enter the name "Mega Account Creator", and click the Create button.
  6. Click OK to dismiss the resulting dialog.
  7. Click the Download JSON button to the right of the client ID.
  8. Move this file to your working directory and rename it client_secret.json.
@zodman
zodman / jira-list
Created July 15, 2022 03:05
jira list tmp
#!/bin/env python
"""
use the api token from jira: https://id.atlassian.com/manage-profile/security/api-tokens
# add to ~/.bashrc
export JIRA_API_TOKEN=""
export JIRA_USER=""
export JIRA_URL="https://myjira.atlassian.net/"
@zodman
zodman / run.bash
Last active July 10, 2022 03:48
Dokku clamav running with scan virus as a service with api rest
##
# this script born about the needs of implement a virus scanner for files using a api rest.
# then using https://github.com/benzino77/clamav-rest-api/ and https://dokkupose.netlify.app
# I create this script to deploy the api rest
##
### dokku apps:destroy clamav-service && dokku apps:destroy clamav-apirest && dokku network:destroy clamav-net
# Let's create a network bridge to communicate
dokku apps:create clamav-service
@zodman
zodman / ajedrez.py
Last active January 10, 2022 23:19
juego de ajedrez en pascal
from colorconsole import terminal
BLANCO = 'blanco'
NEGRO = 'negro'
VACIO = ""
TRenglon = range(0,9)
TColumna = ["A","B","C","D","E","F","G","H"]
screen = terminal.get_terminal()
@zodman
zodman / FDFParser.py
Created October 21, 2021 16:35 — forked from lizettepreiss/FDFParser.py
How to parse a .fdf file in Python. The intention was to export comments I'd made in a .pdf (using Adobe Reader DC's commenting capability) and make them available elsewhere to use as a basis for further notes.
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdftypes import resolve1
# I exported the comments I had made in an Adobe Reader DC document to f:temp/stn.fdf.
# Now I wanted to access those comments outside of the Adobe Reader. Here is how I extracted the comments.
fdf_file = open("F:/temp/stn.fdf", 'rb')