Skip to content

Instantly share code, notes, and snippets.

import re
import string
import unidecode
from nltk.tokenize import sent_tokenize
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
from nltk.corpus import stopwords
import gensim.downloader as api
from pycontractions import Contractions
from word2number import w2n
<!DOCTYPE html>
<meta charset="utf-8">
<style>
div#map-container {
width: 800px;
height: 600px;
}
</style>
<body>
<div id="map-container">
import random
"""
Computes the Convex Hull with the Graham Scan algorithm
Use:
h = ConvexHull()
print(h.hull)
"""
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
body {font-family: helvetica;}
</style>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<div id="chart"></div>
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="//d3js.org/d3-scale-chromatic.v0.3.min.js"></script>
</head>
<body>
<div id="map-container"></div>
<script>
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<script src="http://d3js.org/d3.v4.js"></script>
<link href="https://fonts.googleapis.com/css?family=Assistant&display=swap" rel="stylesheet">
</head>
<body>
<div id="chart"></div>
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<script src="http://d3js.org/d3.v4.js"></script>
<link href="https://fonts.googleapis.com/css?family=Kanit:400,700&display=swap" rel="stylesheet">
</head>
<body>
<div id='tgif-container'>
<div id="tgif-chart"></div>
import random
from PIL import Image
"""
Implements the flood fill algorithm in Python with depth-first search.
Inputs:
-image file
-new image file to write the new image to
-threshold for the color matching
import random
m =[[2,3,3,3,3,3,4,4,4,4,4,4],
[2,3,3,3,3,3,4,4,4,4,4,4],
[3,3,3,1,3,3,4,1,4,4,0,4],
[3,3,1,1,1,3,1,1,1,4,4,4],
[3,1,1,1,1,1,1,1,1,1,4,4],
[3,1,1,0,0,0,0,0,1,1,4,4],
[3,1,1,0,0,0,0,0,1,1,4,4],
[2,1,1,1,1,0,0,0,1,1,2,2],
@lvngd
lvngd / d3_pictogram_demo.html
Created November 20, 2020 17:32
How to build a pictogram grid n D3.js. Demo with Twitter icons.
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<script src="http://d3js.org/d3.v4.js"></script>
</head>
<body>
<div id='grid-container'>
<div id='grid-chart'></div>