Skip to content

Instantly share code, notes, and snippets.

View itslukej's full-sized avatar
🥑

Luke James itslukej

🥑
View GitHub Profile
@itslukej
itslukej / jsonify.js
Last active March 16, 2023 19:47
JSON Serialiser written in pure mongodb aggregate.
db.aggregate([{
$replaceRoot: {
newRoot: {
_id: '$_id',
data: {
$objectToArray: '$$ROOT'
}
}
}
},
@itslukej
itslukej / fix_metadata.sh
Created January 9, 2023 00:47
Fix incorrect metadata for Plex Media Server Linux
#!/bin/sh
/usr/lib/plexmediaserver/Plex\ Media\ Server \
--sqlite /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db \
"UPDATE metadata_items SET added_at = created_at WHERE added_at > strftime('%s', 'now');"
@itslukej
itslukej / bird6.conf
Last active January 17, 2022 11:34
Linux AnyIP IPv6 setup
router id x;
protocol bgp as62240 {
local as 209808;
source address x;
neighbor x as 62240;
import all;
export filter {
if net ~ [2a06:e881:5404::/48] then accept;
@itslukej
itslukej / Captcha.vue
Created May 1, 2021 18:29
hCaptcha vue but better
<template>
<div ref="container"></div>
</template>
<script>
export default {
data() {
return { id: null };
},
navigator.serviceWorker && navigator.serviceWorker.getRegistrations().then(rs => {
rs.forEach(r => {
if (r.active && r.active.scriptURL.includes('arc-sw.js')) {
r.unregister()
}
});
});
@itslukej
itslukej / ads.js
Last active December 6, 2020 14:05
NitroPay Consent Framework x AdSense
function injectAdSense() {
const script = document.createElement('script');
script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
script.async = true;
script.setAttribute('data-ad-client', 'ca-pub-XXXXXXXXXXXXXXXX');
document.head.appendChild(script);
}
<template>
<div>
<span v-for="n in 5" :key=n>
<fa
:icon="[rating >= n ? 'fas' : 'far', 'star']"
@mouseover="rating = n"
@mouseleave="rating = 0"
@click="$emit('rated', rating)"
/>
</span>
local shard_id = tonumber(ARGV[3])
local shard_count = tonumber(ARGV[2])
local prefix = 'cache:' .. ARGV[1] .. ':'
local keys = redis.call('keys', prefix .. '*')
local deleted = 0
for i,v in pairs(keys) do
local key = keys[i]
local guild_id = string.sub(key, #prefix + 1)
import { toBigIntBE, toBufferBE } from 'bigint-buffer';
export function encode(hash: string) {
const buffer = Buffer.from(hash, "hex");
return [toBigIntBE(buffer.slice(0, 8)), toBigIntBE(buffer.slice(8, 16))];
}
export function decode(first: bigint, second: bigint) {
const buffer1 = toBufferBE(first, 8);
use warp::Filter;
use dotenv::dotenv;
use std::env;
#[tokio::main]
async fn main() {
dotenv().ok();
let port = env::var("PORT")
.expect("Port not found")