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
| // @deno-types="npm:@types/sql.js" | |
| import { default as initSqlJs } from "npm:sql.js"; | |
| import { IDatabase, QueryResult } from "./Database.ts"; | |
| export class Database implements IDatabase { | |
| private path: string; | |
| private sqliteJs?: initSqlJs.SqlJsStatic; | |
| private db?: initSqlJs.Database; | |
| private inited = false; |
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
| <?php | |
| add_action("init", function () { | |
| // Ob_start twice, intentionally | |
| ob_start(); | |
| ?> | |
| <script type="module"> | |
| <?php ob_start(); ?> | |
| wp.blocks.registerBlockType("temp/shortcode", { |
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
| use std::sync::mpsc::Sender; | |
| use windows::{ | |
| core::Result, | |
| s, | |
| Win32::{ | |
| Foundation::{HANDLE, HWND, LPARAM, LRESULT, WPARAM}, | |
| System::{ | |
| LibraryLoader::GetModuleHandleA, | |
| Power::{ |
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
| struct MyThreadWrapper { | |
| thread: Option<std::thread::JoinHandle<()>>, | |
| } | |
| impl Drop for MyThreadWrapper { | |
| fn drop(&mut self) { | |
| if let Some(thread) = self.thread.take() { | |
| let _ = thread.join(); | |
| } | |
| } | |
| } |
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
| use windows::{ | |
| core::{GUID, HSTRING}, | |
| Win32::{ | |
| Foundation::HWND, | |
| System::{ | |
| Com::{CoInitializeEx, COINIT_APARTMENTTHREADED}, | |
| Threading::{ | |
| CreateThread, GetCurrentThreadId, WaitForSingleObject, THREAD_CREATION_FLAGS, | |
| }, | |
| }, |
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
| // Dependency free HSTRING implementation | |
| use std::ffi::OsStr; | |
| use std::ffi::{c_void, OsString}; | |
| use std::os::windows::ffi::OsStrExt; | |
| use std::os::windows::ffi::OsStringExt; | |
| type LPCWSTR = *const u16; | |
| type HRESULT = i32; |
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
| // Cargo.toml | |
| // | |
| // [dependencies] | |
| // macro_rules_attribute = "0.1" | |
| #[macro_use] | |
| extern crate macro_rules_attribute; | |
| // How to decorate a function |
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
| #!/bin/bash | |
| HEADERS='Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' | |
| curl -H "$HEADERS" "https://mastodon.social/users/Gargron/statuses/109543381373981313/replies?only_other_accounts=true&page=true" | jq |
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
| <?php | |
| // Show menu item for reusable blocks | |
| add_action('admin_menu', function () { | |
| add_menu_page(_x('Reusable blocks', 'post type general name'), _x('Reusable blocks', 'post type general name'), 'edit_posts', 'edit.php?post_type=wp_block', '', 'dashicons-editor-table', 22); | |
| }); | |
| add_action("should_load_remote_block_patterns", function () { | |
| // I chose `should_load_remote_block_patterns` action because it's triggered |
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
| const worker = new Worker("https://cdn.jsdelivr.net/npm/[email protected]/dist/worker.sql-wasm.js"); | |
| let rpcid = 0; | |
| async function query(sql: string, params: any, action = "exec") { | |
| const id = rpcid++; | |
| return new Promise<any>((res, rej) => { | |
| const listener = (e: MessageEvent<any>) => { | |
| if (e.data && e.data.id === id) { | |
| worker.removeEventListener("message", listener); | |
| res(e.data); | |
| } |