Skip to content

Instantly share code, notes, and snippets.

View attila's full-sized avatar

Attila Beregszaszi attila

View GitHub Profile
@attila
attila / crontab
Last active October 3, 2021 21:57
Roll your own dynamic DNS – check if public IPv4 address has changed, then update it in Linode DNS
# Example crontab
# PATH is extended to include locally installed pip packages, for linode-cli
# m h dom mon dow command
*/15 * * * * PATH=~/.local/bin:$PATH ~/bin/update_dns.sh 2>&1 | logger -t DYN_DNS
@attila
attila / use-decoder.ts
Last active January 21, 2021 21:58
Type assertion / coercion with io-ts
import * as D from "io-ts/Decoder";
import { extract } from "fp-ts/lib/Identity";
import { fold } from "fp-ts/lib/Either";
import { pipe } from "fp-ts/lib/function";
// Utility to assert/coerce type.
export const decodeType = <P>(type: D.Decoder<unknown, P>, value: unknown): P =>
pipe(
type.decode(value),
fold(() => {
@attila
attila / index.js
Created February 1, 2019 14:51
Sequence asynchronous computations
/**
* Run asynchronous computations sequentially
*
* @param {Function} f computation
* @returns {function(*): *}
*/
const sequence = f => entries =>
entries.reduce(
(promise, entry) =>
promise.then(
@attila
attila / index.js
Created February 1, 2019 14:48
Retry with delays
const operation = () => new Promise((resolve, reject) => {
if (Math.random() > 0.8) {
resolve('all good');
} else {
reject(new Error('failure'));
}
});
const pause = duration => new Promise(resolve => setTimeout(resolve, duration));
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 0428bd3..1814aa8 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -2360,6 +2360,10 @@ function _drupal_bootstrap_configuration() {
timer_start('page');
// Initialize the configuration, including variables from settings.php.
drupal_settings_initialize();
+
+ // Sanitize unsafe keys from the request.
@attila
attila / _variables.scss
Created June 8, 2016 08:25
Compile riot tags with Sass styles using @import
$color: red;
(function() {
'use strict';
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {
allowHosts: [
w.location.hostname
]
};
var css = {};
@attila
attila / ufw_expect.sh
Created February 15, 2015 19:13
ufw_expect.sh
#!/usr/bin/expect
set timeout 60
spawn ufw enable
while {1} {
expect {
eof {break}
"Proceed with operation" {send "y\r"}
}
}
@attila
attila / .hgrc
Created February 12, 2015 15:20
Enforce ticket references in Mercurial commit messages in Sourcetree on OS X
[ui]
username=John Doe <johndoen@example.com>
[hooks]
pretxncommit = ~/bin/requireCaseId.sh
@attila
attila / keybase.md
Created September 24, 2014 16:34
keybase.md

Keybase proof

I hereby claim:

  • I am attila on github.
  • I am attila (https://keybase.io/attila) on keybase.
  • I have a public key whose fingerprint is 250D 6A91 F602 62A9 66C7 8ADF E4EC 4774 F1CC 878D

To claim this, I am signing this object: