Skip to content

Instantly share code, notes, and snippets.

Daniel Diekmeier danieldiekmeier

View GitHub Profile
View RetryQueue.js
import async from 'async'
export default class RetryQueue {
constructor (strategy, opts = {}) {
const options = Object.assign({
times: 14,
interval (retryCount) {
return 1000 * Math.pow(2, retryCount)
}
}, opts)
@danieldiekmeier
danieldiekmeier / DoublePunch.js
Created Dec 4, 2018
A basic version of Turbolinks + Stimulus, in blazing small 2kb
View DoublePunch.js
import mitt from 'mitt'
const routeCache = new Map()
const hotCache = new Map()
const instanceCache = new Map()
let latestRequest = null
let isShowingPreview = false
let prevRoute
const eventBus = mitt()
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 = []
You can’t perform that action at this time.