View gist:297d20e95b49daf3ad934e36b1855e82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (main) | |
import Html exposing (Html, text) | |
import Json.Decode as Decode exposing (Decoder) | |
loggingDecoder : Decoder a -> Decoder a | |
loggingDecoder realDecoder = | |
Decode.value | |
|> Decode.andThen |
View paste_table_data_parse_newlines.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Quick and dirty experiment: | |
* Copy cells from a spreadsheet document (excel, libreoffice), and paste in a web page. | |
* Replace the <br /> in the cells with new lines, so when getting the innerHTML or the textContent, | |
* the result is "formatted". | |
*/ | |
document.addEventListener("paste", evt => { | |
const content = evt.clipboardData.getData("text/html"); | |
console.log("content:", content); | |
const parser = new DOMParser(); | |
const doc = parser.parseFromString(content, "text/html"); |
View example.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
There's two ways to create a record in Elm: with the "type constructor" and with the "record syntax". | |
The fact that there's two ways to do the same thing is already a bit disconcerting, but the worst | |
part is that there's no way to do it and have the best of both worlds regarding naming (which is | |
great for clarity, maintenance and refactoring: think about grepping on names for example). | |
-} | |
type alias Person = { | |
firstName: String, |
View mood.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from microbit import * | |
def blink(img): | |
for i in range(5): | |
display.show(img) | |
sleep(200) | |
display.clear() | |
sleep(200) |
View inscrits.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Needs the following libraries: | |
# requests==2.11.1 | |
# unidecode | |
import csv | |
import requests | |
import sys | |
from collections import OrderedDict | |
from unidecode import unidecode | |
# Keys: |
View 34-DifferentPort.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (..) | |
import Html | |
import Html.App | |
import Html.Events | |
import Http | |
import Json.Decode as Json exposing ((:=)) | |
import Task | |
View Http.fromJson.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html | |
import Html.App | |
import Html.Events | |
import Http | |
import Json.Decode as Json exposing ((:=)) | |
import Task | |
url : String | |
url = "http://swapi.co/api/people/1/?format=json" |
View aiohttp + aiopg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""start with: | |
gunicorn utilery.views_aiohttp_aiopg:app -b 0.0.0.0:3579 -w 4 -k aiohttp.worker.GunicornWebWorker""" | |
import asyncio | |
import json | |
import math | |
import time | |
import psycopg2 | |
import psycopg2.extras |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var Validator = require('jsonschema').Validator; | |
var v = new Validator(); | |
var schema = { "allOf" : [ | |
{"type": "boolean"}, | |
{"type": "string"} | |
]} | |
console.log(v.validate("foobar", schema)); |
View watch_turtle.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Reloads the `my_turtle.py` code on save. | |
Put simple turtle instructions in the `my_turtle.py` file, | |
and they'll be re-run (on a clean window) on each file save. | |
Usage: | |
1/ put some turtle instructions in a `my_turtle.py` file | |
(eg `turtle.forward(100)`) | |
2/ run `python watch_turtle.py` on a commandline | |
(no dependencies needed) |
NewerOlder