Skip to content

Instantly share code, notes, and snippets.

@artydev
artydev / async_request_html.py
Created August 27, 2023 21:09
Demonstration of async requests with requests-html
from requests_html import AsyncHTMLSession
session = AsyncHTMLSession()
async def get_cnn():
r = await session.get('https://edition.cnn.com/')
title = r.html.find('title')[0].text
print(title)
@artydev
artydev / .block
Created May 6, 2023 11:50 — forked from nnattawat/.block
Histogram chart using d3.
license: gpl-3.0
height: 620
border: no
@artydev
artydev / histogram.js
Created May 6, 2023 11:45 — forked from vasgat/histogram.js
Draw histogram with d3.js
function histogramChart(color_value, title, xAxisTitle, yAxisTitle, num_of_of_bins) {
var margin = {top: 30, right: 40, bottom: 50, left: 50},
width = 460,
height = 300;
var histogram = d3.layout.histogram(),
x = d3.scale.ordinal(),
y = d3.scale.linear(),
xAxis = d3.svg.axis().scale(x).orient("bottom").tickSize(6, 0),
yAxis = d3.svg.axis()
@artydev
artydev / hellodeno.ts
Last active December 28, 2022 16:00
deno hello
function hello(person: string) {
return "Hello, " + person;
}
console.log(hello("Radddph"));
@artydev
artydev / tinyobs.js
Created December 20, 2022 22:24
Tiny observable using generators
function observable(cb) {
function* _() {
let state = {
title : "State management",
random: 0,
counter : 0
}
while (true) {
let newvalue = yield state;
state = {...state, ...newvalue} ;
@artydev
artydev / multiple_counters.html
Last active October 25, 2022 22:55
MVU Examples
TEST
@artydev
artydev / mvuexamples.json
Last active October 25, 2022 21:57
All MVU Examples
[
{
"titre" : "Simple Counter",
"url" : "https://github.com/artydev/mvu/raw/main/examples/simple-counter.html"
},
{
"titre" : "Multiple Counters",
"url" : "https://github.com/artydev/mvu/raw/main/examples/multiple_counters.html"
},
{
@artydev
artydev / MVU-Counters.js
Created September 26, 2022 07:01
MVU - Staleless Components
//<script src="https://cdn.jsdelivr.net/gh/artydev/mvu@2.0/dist/mvu.umd.js"></script>
//<div id="app></app>
const { dom, udom, m, render } = MVU;
let h1 = m("h1")
let button = m("button")
let div = m("div")
let span = m("span")
let nl = m("br")
@artydev
artydev / mvu-dummyjson.js
Created September 25, 2022 10:51
MVU - Basic use of 'm' function
const { m } = MVU;
let list = m("ul");
let div = m("div");
let li = m("li");
let styleList = `
height: 652px;
overflow:auto;
`
const flipCoin = () => Math.random() < 0.5;
async function sendRequestToServer() {
return new Promise(((resolve, reject) => {
setTimeout(()=> {
if (flipCoin()) {
alert("Oops. An error occurred");
return;
}