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 python3 | |
| import sys | |
| import json | |
| import urllib.request | |
| import urllib.error | |
| import ssl | |
| def verify_aasa(domain): | |
| # Ensure domain doesn't have http/https prefix | |
| if domain.startswith('http://') or domain.startswith('https://'): |
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 | |
| # Check if the correct number of arguments are provided | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: $0 <database_name> <user_name>" | |
| exit 1 | |
| fi | |
| # Command-line arguments | |
| DB_NAME="$1" |
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
| # OS release info | |
| uname -s | |
| uname -r | |
| uname -n | |
| # Start up time | |
| uptime | |
| # CPU info | |
| cat /proc/stat |
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
| pkg install -y wireguard wireguard-tools | |
| cd /usr/local/etc/wireguard/ | |
| umask 077 | |
| wg genkey > freebsd.private | |
| wg pubkey < freebsd.private > freebsd.public | |
| wg genkey > client.private | |
| wg pubkey < client.private > client.public |
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 | |
| set -e; | |
| # Set up a single-node Kubernetes system on Debian 10 (Buster). | |
| # Use Flannel as the network fabric. Install the Kubernetes | |
| # dashboard. | |
| # disable swap | |
| swapoff -a; |
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 ( | |
| "net/http" | |
| "fmt" | |
| "log" | |
| "flag" | |
| "net" | |
| "time" | |
| "runtime" |
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
| @implementation UIImage (Helpers) | |
| - (UIImage *)scaleImageToSize:(CGSize)newSize | |
| { | |
| UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:newSize]; | |
| UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext*_Nonnull myContext) { | |
| [self drawInRect:(CGRect) {.origin = CGPointZero, .size = newSize}]; | |
| }]; | |
| return image; | |
| } |
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
| #import <objc/runtime.h> | |
| NSArray *AllImageNames() { | |
| unsigned int imageCount = 0; | |
| const char **imageNames = objc_copyImageNames(&imageCount); | |
| NSMutableArray<NSString *> *imageNameStrings = [[NSMutableArray alloc] initWithCapacity:imageCount]; | |
| if (imageNames!=NULL) { | |
| for (unsigned int i = 0; i < imageCount; i++){ | |
| const char *imageName = imageNames[i]; | |
| NSLog(@"image name: %s", imageNames[i]); |
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
| // mutex example | |
| // clang++ hello.cpp -std=c++11 -o hello | |
| #include <iostream> // std::cout | |
| #include <thread> // std::thread | |
| #include <mutex> // std::mutex | |
| std::mutex mtx; // mutex for critical section | |
| void print_block (int n, char c) { | |
| // critical section (exclusive access to std::cout signaled by locking mtx): |
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
| // clang attribute.c -o attribute | |
| #include <stdio.h> | |
| int main(int argc, char *argv[]) { | |
| printf("Hello World!\n"); | |
| return 0; | |
| } | |
| __attribute__((constructor)) static void beforeFunction() | |
| { | |
| printf("beforeFunction\n"); |
NewerOlder