This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
LOOK AT THE CONSOLE |
This file contains 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
/** | |
* Get offset relative to selector (or window) | |
* | |
* @param {HTMLElement} el | |
* @param {string|undefined} selector if not give, assumes root most (window) | |
*/ | |
function offsetRelativeTo(el, selector) { | |
let offsetTop = el.offsetTop; | |
let offsetLeft = el.offsetLeft; | |
let offsetParent = el.offsetParent; |
This file contains 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 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 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 function simpleMapEvent<TParam, TRes = void, TContext = unknown>(context?: TContext) { | |
type T = { (this: TContext, inputs: TParam): TRes }; | |
return { | |
cbs: [] as [T, T][], // First value is used for equality check, second is the bound version | |
addListener(cb: T, bindThis?: unknown) { | |
return this.cbs.push([cb, bindThis ? cb.bind(bindThis as TContext) : cb]); | |
}, | |
removeListener(cb: T) { | |
const i = this.cbs.findIndex(([v, _]) => v == cb); | |
if (i >= 0) return this.cbs.splice(i, 1); |
This file contains 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
$t = New-ScheduledTaskTrigger -Once -At (get-date).AddSeconds(10); $t.EndBoundary = (get-date).AddSeconds(60).ToString('s'); Register-ScheduledTask -Force -TaskName JustTrying -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument '-NoProfile -WindowStyle Hidden -command "& {dir}"') -Trigger $t -Settings (New-ScheduledTaskSettingsSet -DeleteExpiredTaskAfter 00:00:01) |
This file contains 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 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 | |
// Mind you, this does not make SVG files safe. This script is meant for sites where only trusted people can upload. | |
add_action("init", function() { | |
// First line of defence defused | |
add_filter('upload_mimes', function ($mimes) { | |
$mimes['svg'] = 'image/svg+xml'; | |
return $mimes; | |
}); |
This file contains 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 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; |