View get-selector-parent.js
const cssTree = require("css-tree@1.0.0-alpha.29"); | |
function getSelectorParent(selector) { | |
const selectorAst = cssTree.parse(selector, { context: 'selector' }); | |
// solution #1 | |
selectorAst.children.prevUntil(selectorAst.children.tail, (node, item, list) => { | |
list.remove(item); | |
return node.type === 'Combinator' || node.type === 'WhiteSpace'; | |
}); |
View minimal-analytics-snippet.js
(function (context, trackingId, options) { | |
const history = context.history; | |
const doc = document; | |
const nav = navigator || {}; | |
const storage = localStorage; | |
const encode = encodeURIComponent; | |
const pushState = history.pushState; | |
const typeException = 'exception'; | |
const generateId = () => Math.random().toString(36); | |
const getId = () => { |
View gist:20b8a0923793d99b682f
server { | |
root /Users/peterbe/dev/MOZILLA/BALROG/balrog-ui/dist; | |
server_name balrog.prod; | |
proxy_set_header Host $host; | |
location ^~ /api/ { | |
proxy_pass http://127.0.0.1:9000; | |
break; | |
} |
View OnBlurComponent.jsx
function OnBlurComponent({ onBlur }) { | |
const handleBlur = (e) => { | |
const currentTarget = e.currentTarget; | |
// Check the newly focused element in the next tick of the event loop | |
setTimeout(() => { | |
// Check if the new activeElement is a child of the original container | |
if (!currentTarget.contains(document.activeElement)) { | |
// You can invoke a callback or add custom logic here | |
onBlur(); |
View convert-subtitles.py
#!/usr/bin/env python | |
# encoding: utf-8 | |
"""Convert caption files to different formats | |
One or more caption files will be converted to the specified output format, saved next to the input file | |
Requires the pycaption library from PBS: https://pypi.python.org/pypi/pycaption/ | |
""" | |
from __future__ import absolute_import, print_function, unicode_literals |