Instantly share code, notes, and snippets.

View json-log.js
import fsExtra from 'fs-extra'
export default function jsonLog (filepath) {
return async function (data) {
await fsExtra.ensureFile(filepath)
await fsExtra.appendFile(filepath, JSON.stringify(data) + '\n')
}
}
View gist:3c1fc91fc7327b85f278aaa1d435036c
.Element {
display none @ <320px; block @ >=320px
font-size 12px @ 320px; 20px @ 1280px
}
.Element {
display (
<320px: none
block
)
View matches-closest.js
var vendor = Element.prototype.matches || Element.prototype.msMatchesSelector
function matches (el, selector) {
if (!el || el.nodeType !== 1) return false;
if (vendor) return vendor.call(el, selector);
return false;
}
function closest (element, selector) {
var parent = element
View Apache Security
<ifModule mod_headers.c>
Header set Connection keep-alive
Header set Strict-Transport-Security "max-age=31536000;"
Header set Content-Security-Policy "script-src 'self'"
Header set X-Frame-Options "Deny"
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
Header set Referrer-Policy ""
Header set Content-Security-Policy "default-src 'self';"
</ifModule>
View 317-counting-elements.py
# from https://www.reddit.com/r/dailyprogrammer/comments/6eerfk/20170531_challenge_317_intermediate_counting/
import re
challenges = """CCl2F2
NaHCO3
C4H8(OH)2
PbCl(NH3)2(COOH)2"""
stack = [{
'elements': {},
View 311.py
# from https://www.reddit.com/r/dailyprogrammer/comments/65vgkh/20170417_challenge_311_easy_jolly_jumper/
challenges = """4 1 4 2 3
5 1 4 2 -1 6
4 19 22 24 21
4 19 22 24 25
4 2 -1 0 2"""
def solve(challenge):
View concatenated_integers.py
# so definiert man eine Funktion
def permutations(numbers):
# wenn die Liste nur eine Zahl enthält,
# können wir sie direkt zurückgeben
if len(numbers) == 1:
return [numbers]
# die leere Liste hier benutzen wir
# um die Ergebnisse zwischenzuspeichern
result = []
View codys_jams.py
prices = [9, 9, 12, 12, 12, 15, 16, 20]
new_prices = []
# The lowest price has to be a reduces price
# Then calculate the original price from that
# remove both from the prices list and do it again
def solve (prices, new_prices):
if len(prices) == 0:
return new_prices
View rolling-average.py
import itertools
import math
items = [10, 3, 4, 10]
steps = 10
def make(a, b):
print(a, b)
result = []