Skip to content

Instantly share code, notes, and snippets.

View david-batranu's full-sized avatar

David Bătrânu david-batranu

View GitHub Profile
@david-batranu
david-batranu / gnupg_scdaemon.md
Created February 26, 2023 16:25 — forked from artizirk/gnupg_scdaemon.md
OpenPGP SSH access with Yubikey and GnuPG

OpenPGP SSH access with Yubikey and GnuPG

Yubikey, Smart Cards, OpenSC and GnuPG are pain in the ass to get working. Those snippets here sould help alleviate pain.

Notes written here should work on

  • Ubuntu 20.04 with Gnome
  • Debian 11 with Gnome
  • Linux Mint with Cinnamon (needs different environment setup, check comments)
  • Arch Linux with Gnome (pacman instead of apt)

This is not a step by step guide

@david-batranu
david-batranu / arch-macbook2018.md
Created August 24, 2020 12:24 — forked from TRPB/arch-macbook2018.md
Guide: Running Arch on a 2018 MacBook Pro

Hardware Prerequisites

You'll need at least the following hardware:

  • At least 3 USB-A to USB-C converters or hub with enough ports for at least 3 USB devices if all your devices are USB-A then:
  • A USB drive
  • A USB keyboard
  • USB to Ethernet adapter, compatible USB dongle or USB tethering on a phone
import logging
import plone.api as api
logger = logging.getLogger(__name__)
def _update_brain(brains, index, column_index, value):
""" Update the brain directly, modifying only the target field
This is much faster than update_metadata=True, as that rebuilds the
entire brain, calling all indexed attributes.
#include <Python.h>
int min(int a, int b, int c) {
int m = a;
if (b < a) { m = b; };
if (c < m) { m = c; };
return m;
}
#include <Python.h>
int main(int argc, char *argv[]) {
const char *s1 = "șustă";
PyUnicodeObject *uo_s1 = PyUnicode_FromString(s1);
Py_ssize_t s_s1 = PyUnicode_GetSize(uo_s1);
Py_UNICODE *c_s1 = PyUnicode_AS_UNICODE(uo_s1);
python2 setup.py build
DEF MAX_STR = 2096
def levenshtein(char* s1, char* s2, int bail_at=5):
cdef int len_s1 = len(s1)
cdef int len_s2 = len(s2)
cdef int v0[MAX_STR]
cdef int v1[MAX_STR]
import gc
import transaction
from zope.globalrequest import getRequest
from Products.CMFCore.utils import getToolByName
import plone.api as api
PROFILE_ID = 'profile-esdrt.content:default'
@david-batranu
david-batranu / python-paged-ldap-snippet-2.4.py
Created April 20, 2018 18:42 — forked from mattfahrner/python-paged-ldap-snippet-2.4.py
This snippet allows you to do a Python LDAP search with paged controls. The latest version now supports Python "ldap" 2.4. Many thanks to Ilya Rumyantsev for doing the 2.4 legwork.
#! /usr/bin/python
import sys
import ldap
from ldap.controls import SimplePagedResultsControl
from distutils.version import LooseVersion
# Check if we're using the Python "ldap" 2.4 or greater API
LDAP24API = LooseVersion(ldap.__version__) >= LooseVersion('2.4')
@david-batranu
david-batranu / constraints.txt
Created April 20, 2018 13:00
Base Plone no-buildout
AccessControl==3.0.11
Acquisition==2.13.11
Babel==1.3
ClientForm==0.2.10
DateTime==3.0.3
DocumentTemplate==2.13.3
ExtensionClass==2.13.2
Jinja2==2.7.3
Markdown==2.0.3
MarkupSafe==1.0