Skip to content

Instantly share code, notes, and snippets.

View jonathanmorgan's full-sized avatar

Jonathan Morgan jonathanmorgan

View GitHub Profile
@jonathanmorgan
jonathanmorgan / git-multi-status.sh
Last active April 12, 2022 15:06 — forked from c0wfunk/git-multi-status.sh
Script for checking git status of many git repositories
#!/bin/bash
# usage: $0 source_dir [source_dir] ...
# where source_dir args are directories containing git repositories
red="\033[00;31m"
green="\033[00;32m"
yellow="\033[00;33m"
blue="\033[00;34m"
purple="\033[00;35m"
@jonathanmorgan
jonathanmorgan / fix-wsl2-dns-resolution
Created December 23, 2021 01:59 — 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.
@jonathanmorgan
jonathanmorgan / README.MD
Created July 1, 2016 12:48 — forked from aanastasiou/README.MD
Generate a Cypher query to store a Python Networkx directed graph

Exporting a Networkx graph as a Cypher query

This little project defines a function that can be used to construct a Cypher query which when executed against a Neo4j database server will store the graph to the server.

Background

  • A Graph is an abstract mathematical model composed of Nodes connected through Edges that can be used to describe complex systems composed of a set of parts (corresponding to nodes) and their connections (corresponding to edges).
  • Examples of graphs are road networks (junctions connected via roads), electronic circuit networks (components and their connections) and others
  • Networkx is an excellent Python module for manipulating such Graph objects of any kind.
  • Neo4j is a graph database. It uses the Graph as a data model to store such objects to a data store.
@jonathanmorgan
jonathanmorgan / queryset_generators.py
Created March 10, 2012 21:29 — forked from mlissner/queryset_generators.py
Adds a date-based queryset generator
from datetime import datetime
from datetime import timedelta
def queryset_generator(queryset, chunksize=1000):
"""
Iterate over a Django Queryset ordered by the primary key
This method loads a maximum of chunksize (default: 1000) rows in its
memory at the same time while django normally would load all rows in its
memory. Using the iterator() method only causes it to not preload all the
@jonathanmorgan
jonathanmorgan / queryset_iterators.py
Created May 6, 2011 05:40 — forked from dbrgn/queryset_generators.py
queryset_generator and queryset_list_generator
'''
queryset_generator and queryset_list_generator based on:
https://gist.github.com/897894
'''
#===============================================================================
# imports (in alphabetical order by package, then by name)
#===============================================================================
# python standard libraries