Skip to content

Instantly share code, notes, and snippets.

View rik's full-sized avatar

Anthony Ricaud rik

View GitHub Profile
@rik
rik / CSVtoJSon.js
Last active February 29, 2024 09:12 — forked from codepo8/CSVtoJSon.js
OK, here is my function to turn CSV into JSON - what's yours?
function _csvRowToArray(csv) {
const csvRegex = /,(?=(?:(?:[^"]*"){2})*[^"]*$)/
const trimQuotes = /^"|"$/g
return csv.split(csvRegex).map(h => h.trim().replace(trimQuotes, ''))
}
function _csvRowToObject(headers, row) {
let currentRow = _csvRowToArray(row)
return Object.fromEntries(headers.map((header, i) => [header, currentRow[i]]))
}
@rik
rik / index.html
Last active October 22, 2021 13:20 — forked from davidbgk/index.html
Opening details tag on hash/anchor
<!doctype html><!-- This is a valid HTML5 document. -->
<!-- Screen readers, SEO, extensions and so on. -->
<html lang="en">
<!-- Has to be within the first 1024 bytes, hence before the `title` element
See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
<meta charset="utf-8">
<meta name="color-scheme" content="light dark">
<!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
<!-- The viewport meta is quite crowded and we are responsible for that.
See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
@rik
rik / cli.sh
Created August 7, 2013 07:48 — forked from karlcow/cli.sh
http GET http://www.otsukare.info/ | grep '<a href="/2' | sed 's,.*<a href="\(.*\)" rel=".*,http://www.otsukare.info\1,' | xargs -n1 http HEAD
@rik
rik / default.diff
Last active December 18, 2015 02:09 — forked from anonymous/default.txt
You'll need to do reset-gaia to give the template app the good permissions (or edit permissions.sqlite).
test_apps/template/index.html | 16 ++++++++++++++++
test_apps/template/manifest.webapp | 6 +++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/test_apps/template/index.html b/test_apps/template/index.html
index 4611ccd..baca876 100644
--- a/test_apps/template/index.html
+++ b/test_apps/template/index.html
@@ -16,6 +16,22 @@
</style>
@rik
rik / template.html
Created March 8, 2012 19:51 — forked from paulrouget/template.html
Empty HTML5 page
<!DOCTYPE html>
<meta charset=utf-8 />
<title>test</title>
<style>
</style>
<div></div>
<!DOCTYPE html>
<html>
<head><title>Event delegation</title></head>
<body>
<ul>
<li><a href="#a"><span>a</span></a></li>
<li><a href="#b"><span><span>b</span></span></a></li>
<li><a href="#c"><span><span><span>c</span></span></span></a></li>
</ul>
<script>