Skip to content

Instantly share code, notes, and snippets.

View WLPhoenix's full-sized avatar

wlphoenix WLPhoenix

View GitHub Profile
@WLPhoenix
WLPhoenix / deepen.py
Last active August 29, 2015 14:09
Python dict deepen
def deepen(shallow_obj):
"""Recursively deepens a dictionary based on keys"""
shallow_copy = copy.copy(shallow_obj)
deep_obj = {}
for key in shallow_copy:
if isinstance(shallow_copy[key], dict):
shallow_copy[key] = deepen(shallow_copy[key])
t = deep_obj
parts = key.split('.')
@WLPhoenix
WLPhoenix / list_licenses.py
Last active January 4, 2021 08:17
Python license lister
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import pkg_resources
def get_pkg_license(pkgname):
"""
Given a package reference (as from requirements.txt),
@WLPhoenix
WLPhoenix / LookbehindSplit.java
Created May 21, 2014 20:09
Java - Split between two characters
import java.util.regex.*;
public class LookbehindSplit {
public static void main(String[] args) {
String split_regex = "((?<=\\])(?=\\[))";
String[] test = "[1][2][3\\]3][4\\[4]".split(split_regex);
for (String s : test) {
System.out.println(s);
}
}