Skip to content

Instantly share code, notes, and snippets.

View akaihola's full-sized avatar
🌇
Working from home

Antti Kaihola akaihola

🌇
Working from home
  • Wärtsilä Oyj
  • Espoo, Finland
View GitHub Profile
@irae
irae / _Stay_standalone.md
Last active January 29, 2024 12:38 — forked from kylebarrow/example.html
Stay Standalone: Prevent links in standalone web apps opening Mobile Safari

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.

@wangtzINT
wangtzINT / core.py
Created March 9, 2012 21:28 — forked from kracekumar/core.py
parallelpip demo 中文版
#! -*- Coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
import gevent
import time
from envoy import run
from sys import exit, argv
import subprocess
import pip
@vontrapp
vontrapp / punch.py
Last active December 22, 2015 22:29 — forked from jimparis/punch.py
#!/usr/bin/python
import ctypes
import ctypes.util
import os
import re
null_re = re.compile('^\0*$')
c_off_t = ctypes.c_int64
@waylonflinn
waylonflinn / ipynb_output_filter.py
Last active May 25, 2018 17:45
Make ipython notebook files place nice with git. Remove output from notebooks when doing diffs and commits.
#! /usr/bin/env python
# this script filters output from ipython notebooks, for use in git repos
# http://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control
#
# put this file in a `bin` directory in your home directory, then run the following commands:
#
# chmod a+x ~/bin/ipynb_output_filter.py
# echo -e "*.ipynb \t filter=dropoutput_ipynb" >> ~/.gitattributes
# git config --global core.attributesfile ~/.gitattributes
# git config --global filter.dropoutput_ipynb.clean ~/bin/ipynb_output_filter.py
@TimSC
TimSC / eertree.py
Last active February 9, 2023 01:12
Implementation of eertree, a palindromic tree in python.
#!/bin/python
#Based on: EERTREE: An Efficient Data Structure for Processing Palindromes in Strings
#by Mikhail Rubinchik and Arseny M. Shur https://arxiv.org/pdf/1506.04862.pdf
#Useful: https://medium.com/@alessiopiergiacomi/eertree-or-palindromic-tree-82453e75025b#.ofgt2r7xn
#Port of https://github.com/zimpha/algorithmic-library/blob/master/string-utility/eertree.cc
#to python by TimSC. zimpha kindly allowed me to release this code under the CC0 license.
from __future__ import print_function
@bbarker
bbarker / PythonTyping.md
Created November 7, 2017 16:13
Using mypy in tests

The following test uses mypy to check the correctness of Python code using typing, largely introduced in 3.5 and 3.6. The two tests check all package code and all test code in the tests directory, respectively. Testing frameworks such as 'nose2' will automatically run the tests and will fail if any typing error is detected (see step #3 below for more on this).

Steps to use

  1. Add the file below to your tests directory, which should be at the top-level in your repository alongside your module directory.
  2. Modify the first line in __init__ that sets self.pkgname to match your library's package name. This assumes one package per repo, so the test would need to be changed if this isn't how the repo structure works.
@laggardkernel
laggardkernel / chpwd-equivalent-in-bash.md
Last active September 5, 2024 20:11
Create chpwd Equivalent Hook in Bash #bash #hook #zsh

There's not a complete hook system designed in Bash when compared with other modern shells. PROMPT_COMMAND variable is used as a hook in Bash, which is equivalent to precmd hook in ZSH, fish_prompt in Fish. For the time being, ZSH is the only shell I've known that has a chpwd hook builtin.

PROMPT_COMMAND

If set, the value is interpreted as a command to execute before the printing of each primary prompt ($PS1).

https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Bash-Variables

chpwd Hook in Bash

@adisbladis
adisbladis / podman-shell.nix
Last active August 22, 2024 00:43
Use podman within a nix-shell
{ pkgs ? import <nixpkgs> {} }:
let
# To use this shell.nix on NixOS your user needs to be configured as such:
# users.extraUsers.adisbladis = {
# subUidRanges = [{ startUid = 100000; count = 65536; }];
# subGidRanges = [{ startGid = 100000; count = 65536; }];
# };
@madkoding
madkoding / pair-dual-boot-bluetooth.md
Last active November 13, 2024 10:37
Pairing bluetooth devices in dual boot with Linux Ubuntu and Windows 10/11

Pairing Bluetooth Devices in Dual Boot with Linux Ubuntu and Windows 10/11

Introduction

This guide provides updated instructions for pairing Bluetooth devices (such as keyboards or mice) in a dual-boot environment with Linux Ubuntu and Windows 10/11, incorporating community feedback and suggestions.

Instructions

1. Pair in Linux First

  • Pair your Bluetooth device in Linux. This is crucial to ensure the LinkKey remains consistent.
  • Note: Do not re-pair the device in Linux after completing the pairing in Windows.
@luochen1990
luochen1990 / venv-py37.nix
Last active November 4, 2024 13:35
Nix Script to simulate FHS environment with python3 & pip & venv
#!/usr/bin/env -S bash -c 'nix-shell --pure $0 -A env'
# Usage:
# 1. run directly to enter bash (inside venv): `./venv-py37.nix`
# 2. build a standalone executable: `nix bundle -f ./venv-py37.nix` #this not works yet since it cause nested `unshare -U` call
# 3. run bash with extra arguments: `nix run -f ./venv-py37.nix '' -- -c 'python --version'`
# More:
# 1. commit id of nixpkgs can be found here: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=python3
let