Skip to content

Instantly share code, notes, and snippets.

[
{
"id": 8505,
"closed": "2015-11-13 11:06:34",
"created": "2015-11-13 05:47:29"
},
{
"id": 8504,
"closed": "2015-11-13 06:11:09",
"created": "2015-11-13 04:47:24"
@wafflespeanut
wafflespeanut / tidy_profile.log
Last active September 14, 2018 06:26
Profiling tidy...
$ python -c "from python import tidy; import cProfile; cProfile.run('tidy.scan()', sort = 'time')" > ~/Desktop/tidy_profile.log
21964378 function calls (21757559 primitive calls) in 936.595 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 544.370 544.370 544.370 544.370 {posix.waitpid}
282745 241.367 0.001 241.367 0.001 {posix.stat}
19007 109.301 0.006 109.301 0.006 {posix.listdir}
# Characters were robbed from http://www.unicode.org/Public/security/revision-06/confusables.txt
# and filtered using Daniel's awesome suggestion for 'printable' ASCII replacements (https://github.com/rust-lang/rust/issues/25957#issuecomment-107812945)
# egrep -v '^[ ]*#' confusables.txt | egrep -v '^[ ]+$|^$' | egrep '00(2[1-9A-F]|3[A-F]|40|5[BCDF]|7[BCD])' | egrep ';[^0-9A-F]00.. ;' | egrep -v '^00' > CONFUSABLES.txt
def const_array_of_strings(name, type_spec = "&'static str"):
return [unicode("const %s: &'static [%s] = &[" % (name, type_spec))]
arrays = [const_array_of_strings('UNICODE_ARRAY', "(char, &'static str, char)"),
const_array_of_strings('ASCII_ARRAY', "(char, &'static str)")]
lengths = map(lambda arr: len(arr[0]), arrays)
@wafflespeanut
wafflespeanut / bubbles.html
Created August 22, 2016 13:36
Viewport anomaly in Chrome!
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
overflow: hidden;
}
.bubble {
position: absolute;
@wafflespeanut
wafflespeanut / test_io.dat
Created January 9, 2017 13:31
Testing SA generation
0: Type map 2024540
0: Bucket heads and tails 2024540
0: Approx SA 3001064
0: Sorting 3001064
0: LMS bytes 2879128
0: Summary Index 2884012
0: Mapping for recursion 2252000
1: Type map 2270432
1: Bucket heads and tails 2270656
1: Approx SA 2557592
@wafflespeanut
wafflespeanut / main.rs
Created August 18, 2018 12:46
HTTP request in Rust using hyper-rustls
#[macro_use] extern crate derive_error;
extern crate futures;
extern crate hyper;
extern crate hyper_rustls;
extern crate tokio_core;
use futures::{Future, Sink, Stream, future};
use futures::sync::mpsc::{self, Sender};
use tokio_core::reactor::Core;
use hyper::client::{Client, HttpConnector};
@wafflespeanut
wafflespeanut / merge_json_objects.swift
Last active September 14, 2018 07:51
Merging inner object fields during encoding
public struct Object: Codable {
let context: String
}
public struct Activity: Codable {
var base: Object
var hello: String
@wafflespeanut
wafflespeanut / Dockerfile
Created September 20, 2018 06:49
Dockerfile for Slate
FROM ruby:2.5-alpine
EXPOSE 4567
RUN apk add --update nodejs g++ make git
RUN git clone https://github.com/lord/slate /usr/src/app
WORKDIR /usr/src/app
RUN bundle install
@wafflespeanut
wafflespeanut / dsv-json.swift
Last active October 9, 2018 13:20
DSV to JSON converter (Swift)
import Foundation
var args = CommandLine.arguments
let name = args.removeFirst()
func printUsage() {
print(
"Usage: \(name) [FILE] -d DELIM [-o OUT_FILE]"
)
}
@wafflespeanut
wafflespeanut / Cargo.toml
Last active January 16, 2019 14:25
TLS Certificate check
[package]
name = "cert-check"
version = "0.1.0"
authors = ["Ravi Shankar <[email protected]>"]
edition = "2018"
[dependencies]
futures = "0.1"
rustls = "0.14"
tokio-core = "0.1"