Skip to content

Instantly share code, notes, and snippets.

View yorickpeterse's full-sized avatar

Yorick Peterse yorickpeterse

View GitHub Profile
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# Background migration for fixing merge_request_diff_commit rows that don't
# have committer/author details due to
# https://gitlab.com/gitlab-org/gitlab/-/issues/344080.
#
# This migration acts on a single project and corrects its data. Because
# this process needs Git/Gitaly access, and duplicating all that code is far
#!/usr/bin/env python
import neovim
import time
import re
import subprocess
def memory_of(pid):
file = open('/proc/{}/status'.format(pid), 'r')
(import bootstrap)
(import std integer)
(import std array)
(import std stdout)
(import std process)
; Defines the "main" module, #f indicating it has no explicit receiver. This means it will be defined
; in the default location.
(let main (defmod bootstrap "main" #f))
# __get_binding_of_caller and __run_code is a compiler hack to invoke VM
# instructions directly.
class Closure:
def construct(code):
let @code = code
let @binding = __get_binding_of_caller(_)
pub def call(args...):
__run_code(_, @code, args, @binding)
aeon $ cat -n /tmp/test.aeon
1 def add(Integer left, Integer right) -> Integer:
2 __get_local(0, 0)
3 __get_local(1, 1)
4 __integer_add(2, 0, 1)
5 __return(2)
6
7 def print(String message) -> Integer:
8 __get_local(0, 0)
9 __stdout_write(1, 0)
require 'socket'
Socket.gethostbyname('localhost') # => ["localhost.localdomain", ["localhost", "x1carbon", "localhost", "x1carbon"], 10, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", "\x7F\x00\x00\x01"]
TCPSocket.gethostbyname('localhost') # => ["localhost.localdomain", ["localhost", "x1carbon", "localhost", "x1carbon"], 10, "::1", "127.0.0.1"]
Numbers indicate the amount of iterations in 5 seconds.
The C example was compiled using:
clang -Wall -Wextra -pedantic -O2 test.c -o test
Results:
C: 2272688181
LuaJIT 170557787 => ~13x slower
Calculating -------------------------------------
Array#[] 201.052k i/100ms
Array#at 194.228k i/100ms
-------------------------------------------------
Array#[] 11.090M (± 2.2%) i/s - 55.490M
Array#at 10.003M (± 1.3%) i/s - 50.111M
Comparison:
Array#[]: 11089538.6 i/s
Array#at: 10002944.7 i/s - 1.11x slower
require 'socket'
server = Socket.new(:INET, :DGRAM)
client = Socket.new(:INET, :DGRAM)
server.bind(Socket.sockaddr_in(0, '127.0.0.1'))
client.connect(Socket.sockaddr_in(server.connect_address.ip_port, '127.0.0.1'))
client.write('hello world how are you doing')
function external-monitor -d 'Enable/disable external monitor'
if [ "$argv[1]" = "on" ]
echo 'Starting bumblebeed...'
sudo systemctl start bumblebeed
echo 'Enabling discrete GPU...'
echo ON | sudo tee /proc/acpi/bbswitch