Skip to content

Instantly share code, notes, and snippets.

@pe3
pe3 / scrape_entire_website_with_wget.sh
Last active March 9, 2024 17:42
Scrape An Entire Website with wget
this worked very nice for a single page site
```
wget \
--recursive \
--page-requisites \
--convert-links \
[website]
```
wget options
@pe3
pe3 / deno-fp-ts-log.ts
Last active April 24, 2021 14:36
Deno fp-ts Hello world
import { log } from "https://cdn.skypack.dev/fp-ts/Console";
log("hello world!")();
// deno run deno-fp-ts-log.ts
// evaluating tree shaking and maximum compability bundles
// see ts-doc for config options https://www.typescriptlang.org/tsconfig
// deno bundle --config tsconfig.json deno-fp-ts-log.ts log-bundle.js
// as of deno 1.9.1 the following options were ignored: module, target
@pe3
pe3 / fizzbuzz.js
Last active February 4, 2018 11:08
declarative javascript sollution to fizzbuzz
// It's more interesting if the numbers are -50 to +50.
const range = (x1,x2) => [...Array(x2-x1+1)].map( (_,i)=>x1+i )
const maybeFizz = x => x%3==0 ? 'fizz' : undefined
const maybeBuzz = x => x%5==0 ? 'buzz' : undefined
const join = (s1,s2) => [s1,s2].join('')
const maybeText = x => join(maybeFizz(x),maybeBuzz(x))
@pe3
pe3 / 0-Code verbosity vs expressiveness.md
Last active September 15, 2017 12:01
Simple fetch based API client implementations
@pe3
pe3 / README.md
Last active September 15, 2017 11:31
a bug in readr R module

The data is from the Finnish ministry of justice election results

curl -O http://tulospalvelu.vaalit.fi/K2012/data/k-2012_ehd_maa.csv.zip
unzip k-2012_ehd_maa.csv.zip
head -n 1 kv-2012_teat_maa.csv > scandinavian.csv
iconv -f ISO-8859-1 -t UTF-8  scandinavian.csv  > scandinavian-utf.csv
$ file -I scandinavian.csv 
scandinavian.csv: text/plain; charset=iso-8859-1
$ file -I scandinavian-utf.csv
@pe3
pe3 / index.js
Last active September 12, 2017 13:15
quite clean and minimal async http call
const r2 = require('r2')
// asynchronous arrow functions seem to need an explicit return to work properly
const loadUser = async id => { return await r2(`https://jsonplaceholder.typicode.com/users/${id}`).json }
(async function() {
console.log(await loadUser(2))
})()
@pe3
pe3 / index.js
Created May 22, 2017 11:06
Programmatically writing to Wikidata
const config = {
// Required
username: 'personal-wikidata-username',
password: 'password',
// Optional
verbose: true // Default: false
}
const wdEdit = require('wikidata-edit')(config)
import React, { PropTypes } from 'react'
import ReactDOM from 'react-dom'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { Provider, connect } from 'react-redux'
import sagaMiddleware, { take, put, fork } from 'redux-saga'
// React component
export class Counter extends React.Component {
render(){
const { value, clickPlus, clickMinus, clickSlow } = this.props
@pe3
pe3 / index.html
Created January 15, 2016 12:33
Simplest React dev boilerplate
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://npmcdn.com/react@0.14.6/dist/react.js" charset="utf-8"></script>
<script src="https://npmcdn.com/react-dom@0.14.6/dist/react-dom.js" charset="utf-8"></script>
<script src="https://npmcdn.com/babel-core@5.8.34/browser-polyfill.min.js" charset="utf-8"></script>
<script src="https://npmcdn.com/babel-core@5.8.34/browser.min.js" charset="utf-8"></script>
</head>
@pe3
pe3 / freeze_tabs.sh
Created September 16, 2013 06:14
Take back your computing resources from Chrome tabs
#!/bin/bash
for i in $(
ps x |
grep 'Google Chrome Helper' |
grep -v grep |
cut -d ' ' -f 1
); do
kill $i;
done