๐
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
| // https://github.com/microsoft/referencesource/blob/master/System.Web/CrossSiteScriptingValidation.cs | |
| private static readonly char[] StartingChars = new char[] { '<', '&' }; | |
| private static bool IsAtoZ(char c) | |
| { | |
| return c is >= 'a' and <= 'z' or >= 'A' and <= 'Z'; | |
| } | |
| private static bool IsDangerousString(string s) | |
| { |
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
| #!/usr/bin/env bash | |
| # JS script paths are absolute in some Ruby docs, convert them to relative. | |
| fd --type file --extension html --full-path 'ruby_.*' --exec sd --string-mode 'src="/js/' 'src="js/' |
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
| func openBrowser(url string) { | |
| var err error | |
| switch runtime.GOOS { | |
| case "linux": | |
| err = exec.Command("xdg-open", url).Start() | |
| case "windows": | |
| err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() | |
| case "darwin": | |
| err = exec.Command("open", url).Start() |
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
| # https://stackoverflow.com/questions/3854692/generate-password-in-python | |
| import string | |
| import secrets | |
| length = 42 | |
| password = "" | |
| for _ in range(length): | |
| l = secrets.choice(string.ascii_lowercase) | |
| u = secrets.choice(string.ascii_uppercase) |
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
| """ | |
| 1. create a separate Firefox profile | |
| 2. start that profile and log into the Google Account of choice | |
| 3. get the profile's path from `about:profiles` | |
| 4. set `profile_url` to the profile's path | |
| 5. run script | |
| """ | |
| from time import sleep | |
| from selenium import webdriver |
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 | |
| if [[ -f "${1}" ]]; then | |
| tmp="${1%.*}" | |
| convert "${1}" \( +clone -background gray -shadow 80x8+8+8 \) +swap -background white -layers merge +repage "${tmp}_drop-shadow.png" | |
| fi |
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
| package main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "log" | |
| "net" | |
| ) | |
| func main() { |
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
| namespace :db do | |
| desc "Kick out PostgreSQL users from the database." | |
| task kick: [:environment] do | |
| begin | |
| ActiveRecord::Base.connection.execute <<-SQL | |
| SELECT pg_terminate_backend(pg_stat_activity.pid) | |
| FROM pg_stat_activity | |
| WHERE pg_stat_activity.datname = '#{ActiveRecord::Base.connection.current_database}'; | |
| SQL | |
| rescue ActiveRecord::StatementInvalid |
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
| """ | |
| https://gitpython.readthedocs.io/en/stable/index.html | |
| """ | |
| import shutil | |
| from git import Repo | |
| repos = { | |
| "github": "[email protected]:vadviktor/test.git", |
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
| package main | |
| import ( | |
| "log" | |
| "os" | |
| "text/template" | |
| ) | |
| func main() { |