Skip to content

Instantly share code, notes, and snippets.

View JPaulMora's full-sized avatar
💭
Follow me on threads https://threads.net/@JPaulMora

John Mora JPaulMora

💭
Follow me on threads https://threads.net/@JPaulMora
View GitHub Profile
@JPaulMora
JPaulMora / nit_is_valid.py
Last active March 10, 2023 16:17
Validar NIT en Python
import re
def nit_is_valid(nit):
if not nit:
return True
nit_regex = re.compile(r'^\d+(-?\d|k|K)?$')
if not nit_regex.match(nit):
return False
@JPaulMora
JPaulMora / womigrate.sh
Last active June 14, 2023 19:06
WordOps full server migration
## WordOps (https://wordops.net/) migration guide/script.
# - This is still in development.
# - most commands will work just as they are.
# - Keep in mind there are some manual instructions.
## Wordops setup in new server
# This is the easiest way to get all the dependencies going in the new host.
# 1. Install
@JPaulMora
JPaulMora / MoneroDiff.js
Created February 7, 2019 18:11
Small node.js snippet to query current monero difficulty from local daemon.
const axios = require('axios');
let header = '';
for (let block = 1685551; block < 1685704; block++) {
axios.post('http://127.0.0.1:18081/json_rpc', '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_height","params":{"height":' + parseInt(block) + '}}').then(resp => {
header = resp.data.result.block_header
console.log(header.height + ', ' + header.timestamp + ', ' + header.difficulty)
})
}
@JPaulMora
JPaulMora / countShares.js
Created February 7, 2019 18:09
Script to manually count snipa's pool shares data from LMDB.
"use strict";
let mysql = require("promise-mysql");
let fs = require("fs");
const range = require("range");
const debug = require("debug")("blockManager");
const async = require("async");
let config = fs.readFileSync("./config.json");
let protobuf = require('protocol-buffers');
this.lmdb = require('node-lmdb');
let comms = require('./lib/local_comms');
@JPaulMora
JPaulMora / launchdocker.sh
Created February 7, 2019 18:07
Script that logs into new docker shell
#!/bin/bash
/usr/bin/docker run -ti ubuntu
IFS=$'\n'
TODAY=$(/bin/date +"%Y-%m-%d")
/usr/bin/docker ps -a -f ancestor=ubuntu --format "{{.ID}} {{.CreatedAt}} {{.Status}}" | while read cont
do
IFS=' '
array=($cont)
@JPaulMora
JPaulMora / dockerfilter.sh
Created February 7, 2019 18:05
Get docker container IDs based on date and if they're exited or not.
#!/bin/bash
IFS=$'\n'
TODAY=$(/bin/date +"%Y-%m-%d")
#CONTAINERS=$(sudo docker ps -a -f ancestor=ubuntu --format "table {{.ID}} {{.CreatedAt}} {{.Status}}")
/usr/bin/docker ps -a -f ancestor=ubuntu --format "{{.ID}} {{.CreatedAt}} {{.Status}}" | while read cont
do
IFS=' '
array=($cont)
#!/bin/sh -e
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 0
fi
TMP=`mktemp -d`
BACK=$TMP/pipe.back
/*
* Number of threads. You can configure them below. Cryptonight uses 2MB of memory, so the optimal setting
* here is the size of your L3 cache divided by 2. Intel mid-to-high end desktop processors have 2MB of L3
* cache per physical core. Low end cpus can have 1.5 or 1 MB while Xeons can have 2, 2.5 or 3MB per core.
*/
"cpu_thread_num" : 1,
/*
* Thread configuration for each thread. Make sure it matches the number above.
* low_power_mode - This mode will double the cache usage, and double the single thread performance. It will
/*
* Number of threads. You can configure them below. Cryptonight uses 2MB of memory, so the optimal setting
* here is the size of your L3 cache divided by 2. Intel mid-to-high end desktop processors have 2MB of L3
* cache per physical core. Low end cpus can have 1.5 or 1 MB while Xeons can have 2, 2.5 or 3MB per core.
*/
"cpu_thread_num" : 2,
/*
* Thread configuration for each thread. Make sure it matches the number above.
* low_power_mode - This mode will double the cache usage, and double the single thread performance. It will