Skip to content

Instantly share code, notes, and snippets.

View xpl's full-sized avatar

Vitalik Gordon xpl

View GitHub Profile
@dabeaz
dabeaz / README.txt
Created October 15, 2019 20:10
PyCon India 2019, Code from Keynote Presentation by @dabeaz
Code from PyCon India 2019 Keynote Talk
David Beazley (https://www.dabeaz.com)
======================================
This code is presented "as is" and represents what was live-coded
during my closing keynote presentation at PyCon India, Chennai,
October 13, 2009. I have made no changes to the files.
Requires: Python 3.6+, numpy, pygame

Why COW was deemed ungood for std::string.

COW, short for copy on write, is a way to implement mutable strings so that creating strings and logically copying strings, is reduced to almost nothing; conceptually they become free operations like no-ops.

Basic idea: to share a data buffer among string instances, and only make a copy for a specific instance (the copy on write) when that instance's data is modified. The general cost of this is only an extra indirection for accessing the value of a string, so a COW implementation is highly desirable. And so the original C++ standard, C++98, and its correction C++03, had special support for COW implementations, and e.g. the g++ compiler's std::string implementations used COW.

So why was that support dropped in C++11?

In particular, would the same reason or reasons apply to a reference counted immutable string value class?

Comparison of Typescript and Flow

Common Features

  • Lots of type inference

  • Null/undefined checking

Similar syntax
@pkazmierczak
pkazmierczak / async-python.py
Last active November 23, 2022 09:49
asyncio example (python3 & python2)
import asyncio
@asyncio.coroutine
def factorial(name, number):
f = 1
for i in range(2, number + 1):
print("Task %s: Compute factorial(%d)..." % (name, i))
yield from asyncio.sleep(1)
f *= i
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@willprice
willprice / .travis.yml
Last active August 15, 2023 17:12
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
@robo-corg
robo-corg / embed_kernel_noloop.py
Created August 15, 2013 01:47
Returns a function that can used to manually pump IPython events to the embedded kernel instead of starting a blocking event-loop.
from IPython.kernel.zmq.kernelapp import IPKernelApp
from IPython.utils.frame import extract_module_locals
import sys
# Code lifted from IPython/kernel/zmq/embed.py
def embed_kernel_noloop(module=None, local_ns=None, **kwargs):
"""Embed and start an IPython kernel in a given scope
returning function that can be used to pump a single event
Parameters
@sebfisch
sebfisch / gist:2235780
Created March 29, 2012 10:47
Laymans explanation of delimited continuations with examples of using them for exception handling and nondeterministic programming.

Delimited Continuations

Delimited continuations manipulate the control flow of programs. Similar to control structures like conditionals or loops they allow to deviate from a sequential flow of control.

We use exception handling as another example for control flow manipulation and later show how to implement it using delimited continuations. Finally, we show that nondeterminism can also be expressed using delimited continuations.

Exception Handling

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: