Skip to content

Instantly share code, notes, and snippets.

View claudiug's full-sized avatar
💜
I eat stickers all the time, dude.

Klaus Heissler claudiug

💜
I eat stickers all the time, dude.
  • cto@relatico
  • Berlin
View GitHub Profile
@noteflakes
noteflakes / chat.rb
Last active November 18, 2021 22:15
Real-world Concurrency with Ruby and Polyphony: a Telnet-based Chat App
# 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
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)
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):
@loilo
loilo / idb-backup-and-restore.md
Last active July 21, 2024 15:30
Back up and restore an IndexedDB database

Back up and restore an IndexedDB database

This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).

Usage

For each of the provided functionalities, you need a connected IDBDatabase instance.

Export Data

import { idb } from 'some-database'
@cshupp1
cshupp1 / gist:1303191f26d653f3a9040114eb2d3fdf
Created September 20, 2019 23:55
jruby script in a jar
#contents of sample.rb
cat sample.rb
require './before'
puts "Hello World!"
#contents of before.rb
cat before.rb
puts "Before..."
#running:
@headius
headius / output.txt
Last active September 19, 2019 19:00
JRuby's new --environment flag
[] ~/projects/jruby $ jruby.bash --environment --dev
JRuby Environment
=================
JRuby executable:
/Users/headius/projects/jruby/bin/jruby.bash
JRuby command line options:
--environment --dev
Environment:
@notozeki
notozeki / Makefile
Last active March 22, 2023 16:27
An example Ruby extension written in Crystal
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)
# 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
@honkskillet
honkskillet / byte-sizetuts.md
Last active July 18, 2024 08:32
A series of golang tutorials with youtube videos.
@miguelgrinberg
miguelgrinberg / pycon-views.py
Last active September 18, 2022 05:41
Generate statistics about PyCon 2014 videos
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'