Skip to content

Instantly share code, notes, and snippets.

View stillyoungman's full-sized avatar
👨‍💻
...

Konstantin stillyoungman

👨‍💻
...
View GitHub Profile
@stillyoungman
stillyoungman / v2ray_wireguard_netflix_spotify_hulu.md
Created August 20, 2023 20:50 — forked from zpoint/v2ray_wireguard_netflix_spotify_hulu.md
v2ray + wireguard to unblock gfw and netflix,spotify,hulu

I previously write a gist about how to set up v2ray + openvpn to unblock gfw and netflix

Refers to that gist for more detail.

In short, this a solution to proxy your network to bypass Firewall with stable connections, and also unblock Proxy detection for Netflix/Spotify/etc....

In my use case from China network:

wireguard

@stillyoungman
stillyoungman / vscode-macos-context-menu.md
Created July 1, 2023 04:21 — forked from idleberg/vscode-macos-context-menu.md
“Open in Visual Studio Code” in macOS context-menu

Open in Visual Studio Code

  • Open Automator
  • Create a new document
  • Select Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
    • your default shell should already be selected, otherwise use /bin/zsh for macOS 10.15 (”Catalina”) or later
    • older versions of macOS use /bin/bash
  • if you're using something else, you probably know what to do 😉
@stillyoungman
stillyoungman / TextFieldTyped.swift
Created February 19, 2022 14:33 — forked from unnamedd/TextFieldTyped.swift
[SwiftUI] Wrapping a UITextField into SwiftUI to use different keyboards, e.g: UIKeyboardType.twitter, UIKeyboardType.numbersAndPunctuation
// Created by Thiago Holanda on 22.06.19.
// twitter.com/tholanda
import SwiftUI
struct ContainerView: View {
@State var decimal = ""
@State var twitter = ""
@State var url = ""
@State var search = ""
@stillyoungman
stillyoungman / jerry.swift
Created December 16, 2021 22:43 — forked from vorce/jerry.swift
Mouse move and click test thing for macos in swift
import Cocoa
import Foundation
// Move around and click automatically at random places in macos, kinda human like in a cheap way.
// Moves the mouse pointer to `moves` random locations on the screen and runs the `action` function at
// each point with the point as argument.
func mouseMoveWithAction(moves: Int, action: (CGPoint) -> Void = defaultAction) {
let screenSize = NSScreen.main?.visibleFrame.size
@stillyoungman
stillyoungman / TextColor.swift
Last active September 7, 2021 06:19 — forked from delputnam/TextColor.swift
Determine if a UIColor is light or dark
// Returns black if the given background color is light or white if the given color is dark
func textColor(for backgroundColor: UIColor) -> UIColor {
var r: CGFloat = 0.0
var g: CGFloat = 0.0
var b: CGFloat = 0.0
var a: CGFloat = 0.0
var brightness: CGFloat = 0.0
backgroundColor.getRed(&r, green: &g, blue: &b, alpha: &a)
// source: https://mobiraft.com/ios/swift/swift-recipe/get-average-colour-from-uiimage/
extension UIImage {
var averageColor: UIColor? {
//A CIImage object is the image data you want to process.
guard let inputImage = CIImage(image: self) else { return nil }
// A CIVector object representing the rectangular region of inputImage .
let extentVector = CIVector(x: inputImage.extent.origin.x, y: inputImage.extent.origin.y, z: inputImage.extent.size.width, w: inputImage.extent.size.height)
guard let filter = CIFilter(name: "CIAreaAverage", parameters: [kCIInputImageKey: inputImage, kCIInputExtentKey: extentVector]) else { return nil }
guard let outputImage = filter.outputImage else { return nil }
#!/bin/sh
# default commands for osx to make it nicer to work with
##########################
# General UI?UX settings #
##########################
# Set hostname (hex of MVB9APPS)
sudo scutil --set ComputerName "0x4d56423941505053"
sudo scutil --set HostName "0x4d56423941505053"
@stillyoungman
stillyoungman / README.swift
Created April 16, 2021 22:26 — forked from dagronf/README.swift
macOS detecting contrast changes using notifications (NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification, NSWorkspace.accessibilityDisplayOptionsDidChangeNotification)
// NSWorkspace.accessibilityDisplayOptionsDidChangeNotification fires when option changes.
// The only thing is, it fires in NSWorkspace's notification center. Not in the default one.
///// Using a selector
NSWorkspace.shared.notificationCenter.addObserver(
self,
selector: #selector(accessibilityDisplayOptionsDidChange(_:)),
name: NSWorkspace.accessibilityDisplayOptionsDidChangeNotification,
object: NSWorkspace.shared)
@stillyoungman
stillyoungman / EmojiCheck.swift
Created October 6, 2020 17:31 — forked from SergLam/EmojiCheck.swift
Swift - check if string contains emoji character
// https://stackoverflow.com/questions/30757193/find-out-if-character-in-string-is-emoji
import Foundation
extension UnicodeScalar {
var isEmoji: Bool {
switch value {
case 0x1F600...0x1F64F, // Emoticons
0x1F300...0x1F5FF, // Misc Symbols and Pictographs
0x1F680...0x1F6FF, // Transport and Map
0x1F1E6...0x1F1FF, // Regional country flags
@stillyoungman
stillyoungman / ParseRSAKeys.java
Created March 15, 2020 13:06 — forked from destan/ParseRSAKeys.java
Parse RSA public and private key pair from string in Java
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;