Skip to content

Instantly share code, notes, and snippets.

  • Start Date: 2022-04-20
  • SEP Status: Draft
  • SEP PR: (leave this empty)
  • Salt Issue: (leave this empty)

Summary

The core team would like to move to an LTS release strategy

@dwoz
dwoz / photon-py3-gdb-debug.md
Last active May 31, 2023 00:42
Debug python3 with gdb on photon linux

Debug python3 process with GDB on Photon Linux

  • Enable the debuginfo package repository.

    In /etc/yum.repos.d/photon-debuginfo.repo change enabled=0 to enable=1.

    /etc/yum.repos.d/photon-debuginfo.repo should look like this

    [photon-debuginfo]
    
@dwoz
dwoz / max_files.py
Last active September 22, 2018 06:54
Windows max files
#!python
from __future__ import print_function
import os, io
import ctypes, logging
import win32file, win32con
import sys
logging.basicConfig()
log = logging.getLogger()
print("Max files before set {}".format(ctypes.windll.msvcrt._getmaxstdio()))
if sys.version_info.major == 2:
@dwoz
dwoz / winconsole.py
Last active September 22, 2018 07:47
Test Setting Codepage from Current Process.
#!python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
import win32console
import os
import sys
import codecs
import sys
@dwoz
dwoz / buildm2.ps1
Last active September 21, 2018 19:03
function Build-M2 {
Param(
[parameter(Mandatory=$true)]
[String]
$PythonExe
)
if ( -not (Get-Command choco -errorAction SilentlyContinue )) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
class TzMapper(object):
def __init__(self, u_to_w):
self.u_to_w = {(k.lower(),v) for k,v in u_to_w}
self.w_to_u = {(v.lower(), k) for k,v in u_to_w}
def add(self, k, v):
self.u_to_w[k.lower()] = v
self.w_to_u[v.lower()] = k
def remove(self, k):
#!/usr/bin/env python3
# simple_tcp_client.py
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
#!/usr/bin/python3
# simple_udp_client.py
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
MESSAGE = "Hello, World!"
@dwoz
dwoz / wsgi_profiler.py
Created July 2, 2017 22:17
Configure profiler via Apache's SetEvn directive
'''
Configure profiler via Apache's SetEvn directive
'''
class Profiler(object):
'''
Simple wrapper around werkzeug's ProfilerMiddleware. This allow enabling
the profile via apache's SetEnv directive:
<powershellArguments>-ExecutionPolicy unrestricted</powershellArguments>
<powershell>
$command = @"
winrm quickconfig -quiet;
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}';
winrm set winrm/config '@{MaxTimeoutms="1800000"}';
winrm set winrm/config/service/auth '@{Basic="true"}';
winrm set winrm/config/service '@{AllowUnencrypted="true"}';
net stop winrm;
sc config winrm start= auto;