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]]))
}
import argparse
import csv
from collections.abc import Generator
from contextlib import contextmanager, closing
from io import TextIOWrapper
from typing import Any
from django.core.management.base import BaseCommand
from django.db import transaction
@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 / simulateTyping.js
Created September 1, 2017 14:30
Fake typing animation with async/await
async function nextFrame() {
return new Promise((resolve) => {
requestAnimationFrame(resolve)
})
}
async function randomDelay(min, max) {
const delay = Math.random() * (max - min) min;
const startTime = performance.now()
while (performance.now() - startTime < delay) {
@rik
rik / feed.xml
Created March 29, 2017 21:46
Microsoft Edge Dev Blog
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">
<channel>
<title>Microsoft Edge Dev Blog</title>
<atom:link href="https://blogs.windows.com/msedgedev/feed/" rel="self" type="application/rss xml"/>
<link>https://blogs.windows.com/msedgedev</link>
<description>Official blog of the Microsoft Edge Web Platform Team</description>
<lastBuildDate>Fri, 24 Mar 2017 16:06:25 0000</lastBuildDate>
<language>en-US</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
@rik
rik / ugly-batch.diff
Created October 23, 2015 15:08
Batch, not so ugly
containers/NavigationContainer.jsx | 37 ---------
1 file changed, 28 insertions( ), 9 deletions(-)
diff --git a/containers/NavigationContainer.jsx b/containers/NavigationContainer.jsx
index 2ae609f..071d35d 100644
--- a/containers/NavigationContainer.jsx
b/containers/NavigationContainer.jsx
@@ -30,6 30,10 @@ import TopNavigationModal from 'Components/Navigation/TopNavigationModal.jsx';
export default React.createClass({
mixins: [i18nContextMixin],
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
<title>Carnets de La Grange</title>
<subtitle>Chroniques d'un po&#xE8;te urbain</subtitle>
<id>tag:la-grange.net,2000-04-12:karl</id>
<updated>2015-09-27T08:21:00Z</updated>
<link href="http://www.la-grange.net/feed.atom" rel="self" type="application/atom xml"/>
<link href="http://www.la-grange.net/" rel="alternate" type="application/xhtml xml"/>
<link href="http://creativecommons.org/licenses/by/2.0/fr/" rel="license"/>
<icon>http://www.la-grange.net/favicon.png</icon>
ensure_endpoint: function() {
if (!navigator.push) {
// Do nothing when push notifications are not supported
console.log('no support for push notifications');
return Promise.resolve();
}
if (ensure_endpoint_in_progress) {
return Promise.resolve();
}
commit 6a5062cfc309c819c9f6958f15b2abc54b66f0c9
Author: Anthony Ricaud <[email protected]>
Date: Sat Jan 5 22:40:15 2013 0100
Don't choke on large git repos
diff --git a/themes/wedisagree.zsh-theme b/themes/wedisagree.zsh-theme
index 9bdbce4..87ab659 100644
--- a/themes/wedisagree.zsh-theme
b/themes/wedisagree.zsh-theme
http_sumo_app: 10:25:43 django.request:ERROR Internal Server Error: /api/2/user/generate: /Users/rik24d/code/kitsune/venv/lib/python2.7/site-packages/django/core/handlers/base.py:224
Traceback (most recent call last):
File "/Users/rik24d/code/kitsune/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 88, in get_response
response = middleware_method(request)
File "/Users/rik24d/code/kitsune/venv/lib/python2.7/site-packages/django/middleware/common.py", line 71, in process_request
if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "/Users/rik24d/code/kitsune/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 600, in is_valid_path
resolve(path, urlconf)
File "/Users/rik24d/code/kitsune/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 480, in resolve
return get_resolver(urlconf).resolve(path)