Skip to content

Instantly share code, notes, and snippets.

View gu-stav's full-sized avatar
🍿

Gustav Hansen gu-stav

🍿
View GitHub Profile
<details>
<summary>yarn@v3</summary>
```
➤ YN0000: ┌ Resolution step
➤ YN0032: │ better-sqlite3@npm:8.0.1: Implicit dependencies on node-gyp are discouraged
➤ YN0061: │ request@npm:2.88.2 is deprecated: request has been deprecated, see https://github.com/request/request/issues/3142
➤ YN0061: │ uuid@npm:3.4.0 is deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
➤ YN0061: │ har-validator@npm:5.1.5 is deprecated: this library is no longer supported
➤ YN0032: │ fsevents@npm:2.3.2: Implicit dependencies on node-gyp are discouraged
@gu-stav
gu-stav / parseLocaleNumber.js
Last active August 9, 2021 08:20
Parse a number-like string to a locale aware Number
const parseLocaleNumber = (input, locale) => {
const formatter = Intl.NumberFormat(locale);
const [, { value: thousandSeparator }] = formatter.formatToParts(11111);
const [, { value: decimalSeparator }] = formatter.formatToParts(1.1);
return parseFloat(input
.replace(new RegExp('\\' + thousandSeparator, 'g'), '')
.replace(new RegExp('\\' + decimalSeparator), '.')
);
}
@gu-stav
gu-stav / keep-focus.js
Created July 2, 2013 07:02 — forked from drublic/keep-focus.js
Keep the focus inside a lightbox/ element. Elegant solution.
var tabbableElements = 'a[href], area[href], input:not([disabled]),' +
'select:not([disabled]), textarea:not([disabled]),' +
'button:not([disabled]), iframe, object, embed, *[tabindex],' +
'*[contenteditable]';
var keepFocus = function (context) {
var allTabbableElements = context.querySelectorAll(tabbableElements);
var firstTabbableElement = allTabbableElements[0];
var lastTabbableElement = allTabbableElements[allTabbableElements.length - 1];
@gu-stav
gu-stav / Readme.md
Last active January 7, 2020 21:57
An accessible HTML-Stepper Component.

#Accessible HTML-Stepper#

It will provide some label-magic through aria-label, so that the buttons actually have a meaning, even if you can't see them.

Styling is not part of it, so you can use whatever you want. The plugin itself doesn't know anything about responsiveness. It does not depend on any plugins.

TODOs/ Ideas

  • Option for limiting the total & minimal Amount
  • Provide Web-Component
  • Let users pass in a set of elements

Notes from Coed:Ethics conference, London, 13 July 2018

Cori Crider - "When data kills" / Weaponised AI

  • Imam Salem bin Ali Jaber preached in Yemen against Islamic extremism; guest at a wedding of relative; hit by a US Hellfire missile fired from a drone. Relative Faisal made contact with Cori, went to Washington DC. No explanation ever made by government (although compensation was paid).
  • Decision-making process behind the attack not known exactly. But there is significant evidence that such attacks serve to further radicalise people; attack results in ~3x more new recruits than extremists killed by attack.
  • Most drone attacks are not on named individuals, but rather "signature strikes" — a euphemism for killing people the military doesn't even know, but who match a certain behavioural pattern (perhaps based on metadata — Hayden: "we kill people based on metadata"
  • Skynet (known through Snowden relevations): use machine learning to try to find courier
@gu-stav
gu-stav / principles.md
Last active June 20, 2018 13:32
Wien.info - Frontend Code Guidelines

Goals

An easy extendable & understandable Codebase, which performs well on all kind of devices. It should provide basic Helpers and In-Code Documentation to develop new features fast and comprehensible way. To achieve this, the Frontend uses the following Technology Stack:

  • Grunt, (Website) for building a release of all resources and to optimize Files
  • LESS (Website), to write less, more structured CSS-Code, which provides re-usable components
  • require.js, (Website) to work with asynchronous JS-Modules, which are loaded, when they are needed
  • Node/ NPM, (Website Nodejs, Website NPM) to install grunt and its dependencies. Run npm install.
@gu-stav
gu-stav / settimeout.js
Last active March 16, 2017 15:17 — forked from gtrufitt/settimeout.js
Test setTimouet
console.log('first script start');
function sleep(milliSeconds){
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu until time's up
}
sleep(2000)
console.log('first script end');
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gu-stav
gu-stav / pseudo-elements.md
Created April 8, 2016 21:21 — forked from p3t3r67x0/pseudo_elements.md
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@gu-stav
gu-stav / test.js
Created September 4, 2013 06:15
nodejs - domains. Taken from http://nodetuts.com/08-domains.html
var EventEmitter = require('events').EventEmitter;
var domain = require('domain');
var fs = require('fs');
var a;
var server = require('http').createServer();
server.on('request', function(req, res) {
var d = domain.create();