Skip to content

Instantly share code, notes, and snippets.

@jfear
jfear / keybindings.json
Created May 10, 2023 01:32 — forked from kevinslin/keybindings.json
Kevin's VSCode Keybindings
// Place your key bindings in this file to override the defaults
[
// The following are Kevin's keybindings for VSCode
// They are made available under CC BY 4.0
//
// To navigate
// `==` denote sections
// `---` denotes subsections
//
// == Dendron
@jfear
jfear / logging_example.py
Created September 1, 2021 13:38 — forked from mbrengel/logging_example.py
Python Logging Setup
#!/usr/bin/env python3
import logging
from logging.handlers import RotatingFileHandler
import sys
import colorama
def configure_logging():
# enable cross-platform colored output
colorama.init()
@jfear
jfear / fix-wsl2-dns-resolution
Created February 26, 2021 12:43 — forked from coltenkrauter/fix-wsl2-dns-resolution
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@jfear
jfear / README-setup-tunnel-as-systemd-service.md
Created February 19, 2019 15:46 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@jfear
jfear / gist:746b9e9201230f8e50eb27abffee60f8
Created May 25, 2017 14:21 — forked from craigminihan/gist:b23c06afd9073ec32e0c
Build GCC 4.9.2 for C/C++ on CentOS 7
sudo yum install libmpc-devel mpfr-devel gmp-devel
cd ~/Downloads
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@jfear
jfear / reference-markdown-metadata-from-jinja-template.py
Created July 27, 2016 21:02 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
c = get_config()
### If you want to auto-save .html and .py versions of your notebook:
# modified from: https://github.com/ipython/ipython/issues/8009
import os
from subprocess import check_call
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py scripts"""
if model['type'] != 'notebook':
return # only do this for notebooks