Skip to content

Instantly share code, notes, and snippets.

@mortn
mortn / geoblocker
Last active April 24, 2024 16:55
nginx geoip blocking with network exceptions.
# /etc/nginx/geoblocker
# This will block anything but the defined countries and the networks defined in the $localnet variable
set $geoblock 0;
if ($geoip_country_code !~ (DK|NO|SE)) { set $geoblock 1; }
if ($localnet = 1){ set $geoblock 0; }
if ($geoblock = 1){ return 403; }
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
import requests
from bs4 import BeautifulSoup
from langchain.schema.runnable import RunnablePassthrough, RunnableLambda
from langchain.utilities import DuckDuckGoSearchAPIWrapper
import json
RESULTS_PER_QUESTION = 3
@Mearman
Mearman / Obsidian Snippets
Last active April 24, 2024 16:52
Obsidian Snippets
A collection of snippets
@zackpyle
zackpyle / fluent-forms-dynamic-submit-button-text.php
Created April 24, 2024 14:28
Fluent Forms - Use shortcode attr and FF SmartCode to pass dynamic Submit Button text
<?php
// Register Fluent Forms SmartCode
add_filter('fluentform/editor_shortcodes', function ($smartCodes) {
$smartCodes[0]['shortcodes']['{submit_button_text}'] = 'Dynamic Submit Button Text';
return $smartCodes;
});
// Use text from submit_button_text attribute on the form's shortcode
add_filter('fluentform/editor_shortcode_callback_submit_button_text', function ($value, $form) {
@0xdevalias
0xdevalias / _deobfuscating-unminifying-obfuscated-web-app-code.md
Last active April 24, 2024 16:51
Some notes and tools for reverse engineering / deobfuscating / unminifying obfuscated web app code
@deanhume
deanhume / clear-cache.js
Created September 20, 2017 08:22
Clear Service Worker Cache
if ('serviceWorker' in navigator) {
caches.keys().then(function(cacheNames) {
cacheNames.forEach(function(cacheName) {
caches.delete(cacheName);
});
});
}
@thesamesam
thesamesam / xz-backdoor.md
Last active April 24, 2024 16:46
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that

@nicolevanderhoeven
nicolevanderhoeven / updateDate.js
Created May 8, 2023 15:42
Gist for automatically adding a link to today's daily note to an Dataview inline field in an Obsidian note. For use with the QuickAdd Obsidian plugin.
module.exports = async function updateDate(params) {
/*
This function does the following things:
1. Gets the current date.
2. Reads the contents of the current file.
3. When a line that contains `date::` is found, adds the current date as a note to the end of the line.
*/
let currDate = moment().format('YYYY-MM-DD');
const currentFile = params.app.workspace.getActiveFile();
const fileContents = await params.app.vault.read(currentFile);
@schriker
schriker / OTPInput.tsx
Created September 4, 2022 06:54
Simple React Native One Time Password Input
import React, { useRef } from 'react'
import { NativeSyntheticEvent, TextInput, TextInputKeyPressEventData, View } from 'react-native'
import { useStyles } from 'lib/hooks'
import { createStyles } from 'lib/styles'
import { Nullable } from 'lib/types'
type OTPInputProps = {
length: number,
value: Array<string>,
disabled: boolean,
@AndrewFarley
AndrewFarley / generate-random-1gb-csv.py
Last active April 24, 2024 16:42
This simple Python file generates a random massive CSV file efficiently taking almost no RAM while doing so streaming data into your CSV file. I've pre-done the calculation of the rows/columns to the file-size, so you can easily add or remove zeroes from "rows" variable to increase or decrease the size of the file generated
import csv
import random
# 1000000 and 52 == roughly 1GB (WARNING TAKES a while, 30s+)
rows = 1000000
columns = 52
print_after_rows = 100000
def generate_random_row(col):
a = []