Skip to content

Instantly share code, notes, and snippets.

/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
import duckdb from "duckdb";
import assert from "node:assert";
import { tableFromIPC, RecordBatchReader, Table, Int32, makeData, Vector } from "apache-arrow";
const RANGE_SIZE = 1_000;
const SQL = `select * from range(0,${RANGE_SIZE}) tbl(i)`;
const expectedTable = new Table({
import { Connection, PublicKey, clusterApiUrl } from '@solana/web3.js';
(async () => {
const conn = new Connection(
process.env.RPC_URL ?? clusterApiUrl('mainnet-beta'),
'confirmed'
);
// From https://orca-so.gitbook.io/orca-developer-portal/whirlpools/interacting-with-the-protocol/orca-whirlpools-parameters
const whirlpoolProgramId = new PublicKey('whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc');
@matt-allan
matt-allan / README.md
Created July 31, 2020 20:49
Compound sorting Laravel collections

This is an example of sorting a Laravel collection by > 1 attribute with different sort directions. Unlike some of the other solutions mentioned in this thread it works with any type PHP can normally sort and doesn't require hashing.

That works because of how PHP's comparison functions work:

Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value

The <=> operator is PHP's combined comparison operator, or 'spaceship' operator. It makes writing custom sort functions very easy.

If you need to do a compound sort but every attribute is being sorted in the same direction, you can use sortBy/sortByDesc instead of writing your own sort function.

@matt-allan
matt-allan / index.html
Last active January 6, 2022 17:47
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Context Bridge Example</title>
<link rel="stylesheet" type="text/css" href="./styles.css">
</head>
<body>
<main class="app">
<button onclick="window.app.setFullscreen(true)">Enter fullscreen</button>
{
// You can extend the same config file typescript uses to avoid drift
"extends": "./base.json",
// Accepts globs. Works just like TypeScript
"include": [
"src/wiretypes/**"
],
"exclude": [
"src/wiretypes/*.test.ts"
],
@matt-allan
matt-allan / keybase.md
Created April 12, 2020 17:54
keybase.md

Keybase proof

I hereby claim:

  • I am matt-allan on github.
  • I am mattya (https://keybase.io/mattya) on keybase.
  • I have a public key ASCD9RfpRxzyrRfF79o7vA-ANxS6WBJTb785HRo1NsZnIwo

To claim this, I am signing this object:

@matt-allan
matt-allan / Caddyfile
Last active March 26, 2019 13:49
PHP Httpoxy example
localhost:8080
fastcgi / 127.0.0.1:9000 php {
env HTTP_AUTH_PASSWORD secret123
}
rewrite {
regexp .*
ext /
to /index.php?{query}
@matt-allan
matt-allan / Caddyfile
Created March 22, 2019 23:24
Caddyfile for PHP bug 77782
localhost:8080
fastcgi / 127.0.0.1:9000 php {
env FOO bar
}
rewrite {
regexp .*
ext /
to /index.php?{query}
0.0.0.0
root ./
gzip
fastcgi / 127.0.0.1:9000 php {
env FOO bar
}
rewrite {
regexp .*
ext /
to /index.php?{query}
@matt-allan
matt-allan / croutonGamepadFix.md
Last active November 3, 2017 16:45
setup dragonrise controllers with crouton

To make dragonrise n64 and snes controllers work with my crouton xfce4/ubuntu chroot, I had to recompile the kernel with support for the hid_dr module. These are the steps to get the controllers working. Almost all steps are taken from the sources listed below. All commands are entered in the chroot's terminal, not the chronos shell.

sudo apt-get install git-core make kernel-package
cd ~
git clone https://chromium.googlesource.com/chromiumos/third_party/kernel -b chromeos-3.8
cd kernel
nano chromeos/config/base.config

type ctrl-w, type 'error_on_warning' and press enter to find the line you need to edit.