Skip to content

Instantly share code, notes, and snippets.

View SteveAlexander's full-sized avatar

Steve Alexander SteveAlexander

View GitHub Profile
import trio
import random
from collections import deque
WORKER_COUNT = 10
tasks = range(103)
class WorkQueue:
def __init__(self, workers):
@blaylockbk
blaylockbk / numpy_datetime_to_datetime.py
Last active March 1, 2024 20:24
Convert numpy.datetime64 to datetime.datetime
from datetime import datetime
import numpy as np
def to_datetime(date):
"""
Converts a numpy datetime64 object to a python datetime object
Input:
date - a np.datetime64 object
Output:
DATE - a python datetime object
@konradko
konradko / iBeacon-JINOU-BEC05.md
Last active August 29, 2018 19:32
Updating iBeacon JINOU BLE JO-BEC05 JO-BEC03 CC2540/CC2541 advertisement data

PIN code: 000000

Set them up using an iOS app:

  1. Install Lightblue Explorer from App store
  2. Connect to 'JinouBeacon'
  3. Enter the PIN 000000 to pair the device
  4. Editable values are in UUID:F350 section
  5. Covert strings / numbers to HEX before writing
@tomysmile
tomysmile / mac-setup-redis.md
Last active March 18, 2024 22:12
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@marick
marick / about_those_lava_lamps.md
Last active June 22, 2022 21:08
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

defmodule HammingBench do
use Benchfella
use Bitwise
@n Stream.repeatedly(fn -> Enum.random [0, 1] end)
|> Enum.take(100_000)
|> Enum.join
|> String.to_integer(2)
bench "CharlesO" do
@davenotik
davenotik / util.dart
Last active December 2, 2018 10:57
Custom readHttp() as an alternative to http.read().
import 'dart:convert';
import 'dart:async';
import 'dart:io';
import 'package:http/http.dart' as http;
/**
* A utility method that reads HTTP response body and returns it as a string.
*
* The difference to http.read() is: send good headers, handle encodings better and have a timeout.
@sirex
sirex / main.py
Last active April 5, 2024 19:31
sqlalchemy joins with AS
import sqlalchemy as sa
import sqlparse
metadata = sa.MetaData()
tasks = sa.Table(
'tasks', metadata,
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('bot', sa.String(255), nullable=False),
sa.Column('task', sa.String(255), nullable=False),