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
/* 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 / 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 / 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')
[
{
"objectId": "hKljil8WpZ",
"ProgrammingLanguage": "@Formula",
"Source": "http://en.wikipedia.org/wiki/Formula_language",
"createdAt": "2020-02-06T16:22:51.408Z",
"updatedAt": "2020-02-06T16:22:51.408Z"
},
{
"objectId": "chpqVvCNF3",
@zodman
zodman / store-secrets-githubactions .py
Created October 30, 2020 19:11
store github secrets from env enviroment
import sys
from dotenv import dotenv_values
"""
# pip install python-dotenv
# using https://github.com/anomaly/github-secrets-cli
main.py .secretsenv org repo | bash
"""
def main():
e =dotenv_values(dotenv_path=sys.argv[1])
@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 / intro.md
Created June 6, 2020 03:13 — forked from GochoMugo/intro.md
Node.js Debug Package as a Dev-Dependency

The [debug][debug] module for Node.js is one of the most useful utilities when it comes to high-level debugging. The only problem with using it, would that the module eventually becomes a hard dependency in your project. Your project will NOT run if the package is not installed despite the fact that it is only needed in development mode.

One way to work around this to have a dummy function used in place of the real debug function, when users are in production mode.

var debug = process.env.DEBUG ? require("debug")("MyProject:Server") : function() {};

This way, the module is only loaded when the DEBUG environment variable is set. Therefore, the package can be added as a devDependency to the project's package.json rather than as a dependency.

@zodman
zodman / featureflag.js
Created February 26, 2020 22:25
Simple featureflag in nodejs
/*
* Simple featureFlag
* */
const YAML = require('yaml');
const fs = require("fs");
class FeatureFlag {
constructor() {
set $var_cors 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,X-app-language,X-app-version,X-app-countr';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,X-app-language,X-app-version,X-app-country';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;