Skip to content

Instantly share code, notes, and snippets.

View manuphatak's full-sized avatar
🎯
Focusing

Manu Phatak manuphatak

🎯
Focusing
View GitHub Profile

ADR #0001: MusixMatch API

Date: 2020-07-09

Who

Status

# Response to:
# http://blog.honeybadger.io/how-openstruct-and-hashes-can-kill-performance/
#
# It's not faire to use `Hash.new.merge(data)` if you can `Hash[data]`.
# `Hash[data]` is way faster! Lets compare!
#
# Read more: http://ruby-doc.org/core-2.2.0/Hash.html#method-c-5B-5D
#
# [UPDATE]
#
@manuphatak
manuphatak / package.json
Last active June 23, 2019 06:11
phaser-types
{
"name": "phaser-types",
"author": "Manu Phatak",
"version": "3.18.1",
"types": "phaser.d.ts",
"peerDependency": {
"phaser": "3.18.1"
}
}
@manuphatak
manuphatak / package.json
Created June 23, 2019 05:45
phaser-types
{
"name": "phaser-types",
"author": "Manu Phatak",
"version": "3.18.1",
"types": "./phaser.d.ts"
"peerDependency": {
"phaser": "3.18.1"
}
}
@manuphatak
manuphatak / run.py
Last active September 8, 2017 17:21
Run hackerrank maze escape locally. https://www.hackerrank.com/challenges/maze-escape/
# /usr/bin/env python
# coding=utf-8
from __future__ import print_function
import json
import os.path
import shutil
import subprocess
import sys
from argparse import ArgumentParser, FileType
@manuphatak
manuphatak / convert-posts-to-portfolio.md
Last active July 25, 2018 19:38
WordPress: convert posts to jetpack portfolio entries

Executive summary

Use the import + export tool and a text editor to replace a few data points.

  1. Export your posts to xml
  2. Use a text editor with a search + replace tool to replace a few fields
  3. Import the updated xml

Search + replace details

@manuphatak
manuphatak / pipeline.py
Last active December 12, 2015 07:03
Idiomatic text processing. Inverting reduce: instead of running one function on a list of values, run a list of functions on one value.
from functools import reduce
def pipeline(steps, initial=None):
def apply(result, step):
yield from step(result)
yield from reduce(apply, steps, initial)
if __name__ == '__main__':
# BEFORE
@manuphatak
manuphatak / atexit_setup.py
Created December 8, 2015 05:47
Dealing with `atexit` and setup.py test command deleting modules.
from setuptools import setup
from setuptools.command.test import test as TestCommand
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
@manuphatak
manuphatak / default_args_class_decorator.py
Created September 20, 2015 22:08
Class decorator that overrides default kwargs.
from functools import wraps
def defaults(method='__init__', **default_args):
"""Class decorator. Overrides method default arguments."""
def decorate(cls):
func = getattr(cls, method)
@wraps(func)
@manuphatak
manuphatak / css_class.py
Created September 20, 2015 21:43
Django css class tag. Combine conditional classes.
# Python Libraries
import re
# Django Packages
from django import template
register = template.Library()
_re_camel_humps = re.compile('([a-z])([A-Z0-9])')
"""