Skip to content

Instantly share code, notes, and snippets.

@mavhc
mavhc / gist:1048c2ca96418c2b283d1b725a18ce50
Created March 25, 2024 14:32
Upgrade Freepbx 15 to 16 using OSSEPM endpointman
Backup sql tables:
mysqldump asterisk endpointman_brand_list endpointman_custom_configs endpointman_global_vars endpointman_line_list endpointman_mac_list endpointman_model_list endpointman_oui_list endpointman_product_list endpointman_template_list > ossepm.sql
Remove endpointman
Upgrade Freepbx to v16
Download zip from https://github.com/unex/endpointman
upload module, choose file, manage local, install
Restore sql tables:
mysql asterisk < ossepm.sql
@mavhc
mavhc / snipeit.ps1
Created January 25, 2024 11:08
code to automate inventory
$apikey = "..."
$url = "https://..."
#Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
write-output "Install NuGet"
Install-PackageProvider NuGet -Force
if(-not (Get-Module SnipeitPS -ListAvailable)){
write-output "Install SnipeitPS"
Install-Module SnipeitPS -Force
}
from bs4 import BeautifulSoup
import urllib.request
import re
html = urllib.request.urlopen("https://www.cc.com/shows/the-daily-show-with-trevor-noah")
soup = BeautifulSoup(html,'html.parser')
for link in soup.findAll('a', text=re.compile(".*LATEST EPISODE.*")):
print(link.get('href'))
import itertools
cnts=[[0,0,0,25,0],[9,0,0,0,0],[0,0,32,0,0],[0,0,0,0,16],[0,0,14,0,0]]
def getTotal(col):
return cnts[0][col]+cnts[1][col]+cnts[2][col]+cnts[3][col]+cnts[4][col]
for r0 in itertools.permutations([17,21,8,29],4):
for r1 in itertools.permutations([30,26,13]):
for r2a in itertools.permutations([15,11]):
@mavhc
mavhc / join.py
Created February 21, 2017 10:53
Join mp4 files with ffmpeg
# join.py
# CC-0
# usage: python3 join.py filename
# all files that start with filename in the current dir will be found, sorted, and joined together with ffmpeg
# mp4 assumed
import os, glob, sys, subprocess
name = sys.argv[1]
print(name)
fileList = glob.glob(name+"*")
# See https://www.youtube.com/watch?v=L8egrL-WC-0
import microbit
def pick_speed(speed):
while not microbit.button_b.is_pressed():
microbit.display.show(str(speed))
if microbit.button_a.is_pressed():
speed -= 1
if speed < 1: speed = 9
microbit.sleep(200)
@mavhc
mavhc / maze.py
Created February 18, 2016 16:38
import microbit, random
# from Python 3 source
def shuffle(x):
for i in reversed(range(1, len(x))):
# pick an element in x[:i+1] with which to exchange x[i]
j = int(random.random() * (i+1))
x[i], x[j] = x[j], x[i]
# correct viewport onto maze so the whole screen is always used
import microbit, random
# blank grid to start
gridImg = microbit.Image("00000\n"
"00000\n"
"00000\n"
"00000\n"
"00000\n")
def get_grid():
return [[microbit.display.get_pixel(x,y) for y in range(5)] for x in range(5)]
import microbit, random
# background oxo grid at brightness 1
gridImg = microbit.Image("00000\n"
"00000\n"
"00000\n"
"00000\n"
"00000\n")
# returns False is a square is blank
def check_squares_filled():
# put this file, and ffmpeg.exe in a folder, drop videos onto this file
# a version called filename-rotatedcounterclockwise.ext will be saved
# in the same folder as the original
import sys
import subprocess
import os
from pathlib import Path
i = sys.argv[1]
#print(i)