Skip to content

Instantly share code, notes, and snippets.

"""
lark_tree_to_json.py
How can I convert the output of lark().parse() into JSON #618
https://github.com/lark-parser/lark/issues/618
Lark parser, LALR & Earley, Python
https://github.com/lark-parser/lark
https://lark-parser.readthedocs.io/en/latest/
https://pypi.org/project/lark-parser/
@JJediny
JJediny / gist:a466eed62cee30ad45e2
Created October 5, 2015 20:42
Jekyll Liquid Cheatsheet

There are two types of markup in Liquid: Output and Tag.

  • Output markup (which may resolve to text) is surrounded by
{{ matched pairs of curly brackets (ie, braces) }}
  • Tag markup (which cannot resolve to text) is surrounded by
@hi2p-perim
hi2p-perim / loadhdr.py
Created March 4, 2014 12:48
Load Radiance HDR file (.hdr) with python. Used : smc.freeimage, Pillow, OpenCV
import array
import smc.freeimage as fi
from PIL import Image
import numpy as np
import cv2
def gamma_correction(a, gamma):
return np.power(a, 1/gamma)
def load_hdr(file):
@mcleonard
mcleonard / vector.py
Last active February 22, 2024 12:30
A vector class in pure python.
import math
class Vector(object):
def __init__(self, *args):
""" Create a vector, example: v = Vector(1,2) """
if len(args)==0: self.values = (0,0)
else: self.values = args
def norm(self):
""" Returns the norm (length, magnitude) of the vector """
@gruber
gruber / inline2ref.rb
Created September 9, 2011 21:25 — forked from ttscoff/inline2ref.rb
Convert inline Markdown links to references
#!/usr/bin/env ruby
def e_sh(str)
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
end
def find_headers(lines)
in_headers = false
lines.each_with_index {|line, i|
if line =~ /^\S[^\:]+\:( .*?)?$/
@chrisjacob
chrisjacob / README.md
Created February 18, 2011 03:44
Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result