by alexander white ©
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See also: https://noteflakes.com/articles/2021-11-13-real-world-polyphony-chat | |
require 'polyphony' | |
server = spin do | |
server_socket = TCPServer.new('0.0.0.0', 1234) | |
server_socket.accept_loop do |s| | |
spin { handle_session(s) } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'webrick' | |
# How much of this is solved by frozen string literal? | |
Ractor.make_shareable(WEBrick::Config::HTTP) | |
Ractor.make_shareable(WEBrick::LF) | |
Ractor.make_shareable(WEBrick::CRLF) | |
Ractor.make_shareable(WEBrick::HTTPRequest::BODY_CONTAINABLE_METHODS) | |
Ractor.make_shareable(WEBrick::HTTPStatus::StatusMessage) | |
# To pick up changes from https://github.com/ruby/ruby/pull/4007 | |
Object.send(:remove_const, :URI) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import boto3 | |
from PySide2.QtCore import QRunnable, QObject, QThreadPool, Signal, Slot | |
from PySide2.QtWidgets import QMainWindow, QVBoxLayout, QProgressBar, QPushButton, QWidget, QApplication | |
class TestWindow(QMainWindow): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Export all data from an IndexedDB database | |
* | |
* @param {IDBDatabase} idbDatabase The database to export from | |
* @return {Promise<string>} | |
*/ | |
export function exportToJson(idbDatabase) { | |
return new Promise((resolve, reject) => { | |
const exportObject = {} | |
if (idbDatabase.objectStoreNames.length === 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#contents of sample.rb | |
cat sample.rb | |
require './before' | |
puts "Hello World!" | |
#contents of before.rb | |
cat before.rb | |
puts "Before..." | |
#running: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[] ~/projects/jruby $ jruby.bash --environment --dev | |
JRuby Environment | |
================= | |
JRuby executable: | |
/Users/headius/projects/jruby/bin/jruby.bash | |
JRuby command line options: | |
--environment --dev | |
Environment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CRYSTAL = crystal | |
UNAME = "$(shell uname -ms)" | |
LIBRARY_PATH = $(shell brew --prefix crystal-lang)/embedded/lib | |
LIBS = -levent -lpcl -lpcre -lgc -lpthread | |
LDFLAGS = -Wl,-undefined,dynamic_lookup | |
TARGET = crystal_example_ext.bundle | |
$(TARGET): crystal_example_ext.o | |
$(CC) -bundle -L$(LIBRARY_PATH) -o $@ $^ $(LIBS) $(LDFLAGS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# speed up pluck | |
class ActiveRecord::Relation | |
class RailsDateTimeDecoder < PG::SimpleDecoder | |
def decode(string, tuple=nil, field=nil) | |
if Rails.version >= "4.2.0" | |
@caster ||= ActiveRecord::Type::DateTime.new | |
@caster.type_cast_from_database(string) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import re | |
from multiprocessing.pool import ThreadPool as Pool | |
import requests | |
import bs4 | |
root_url = 'http://pyvideo.org' | |
index_url = root_url + '/category/50/pycon-us-2014' | |
NewerOlder