Skip to content

Instantly share code, notes, and snippets.

View salexkidd's full-sized avatar

salexkidd salexkidd

  • Japan Tokyo
View GitHub Profile
@salexkidd
salexkidd / gist:04d01112462fb66c6da5019d1379cdb4
Created April 12, 2023 03:29
Minimize Discord window when zoom lunched
repeat
delay 1
tell application "Finder"
name of every process whose visible is true and name is "Zoom.us"
if the result as Unicode text is "Zoom.us" as Unicode text then
tell application "System Events" to set visible of process "Discord" to false
end if
end tell
end repeat
@salexkidd
salexkidd / gist:703f8d79cdb3b0182b1945d4248c8bb7
Created April 14, 2019 13:53
Public key encryption with cryptography
import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
# Create Private Key
private_key = rsa.generate_private_key(
var res: NSResponder? = self.nextResponder
print("---------------------------------------------")
while(true)
{
if res == nil { break }
print(res)
res = res?.nextResponder
}
@salexkidd
salexkidd / NSScreen+someOfFunc.swift
Last active June 10, 2021 19:05
NSScreen+someOfFunc.swift
import Cocoa
extension NSScreen {
public var displayID: CGDirectDisplayID {
get {
return deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as! CGDirectDisplayID
}
}
@salexkidd
salexkidd / gist:baf9b8a847fc6780db1e12c57c27c7db
Created January 24, 2018 08:07
ちなみに UserDefaults.didChangeNotification だと1回しかきてないとかいいよる
import Cocoa
let testKey: String = "TESTKEY"
let userDefaults: UserDefaults = UserDefaults.standard
let defaultCenter: NotificationCenter = NotificationCenter.default
// Remove Perferences & register default
userDefaults.removePersistentDomain(forName: Bundle.main.bundleIdentifier!)
userDefaults.register(defaults: [testKey : false])
@salexkidd
salexkidd / KVOProblem.swift
Last active May 14, 2020 05:45
UserDefaults.standard.addObserver calling observeValueForKeyPath multiple times
import Cocoa
let testKey: String = "TESTKEY"
let defaults: UserDefaults = UserDefaults.standard
// Remove Perferences & register default
defaults.removePersistentDomain(forName: Bundle.main.bundleIdentifier!)
defaults.register(defaults: [testKey : false])
class testClass: NSObject {
@salexkidd
salexkidd / CallTwiceObserveProblem
Last active January 22, 2018 11:56
observeValueForKeyPathが二度呼ばれてしまう問題...
#import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
<html>
<script type="text/javascript">
var sougaku = 5000;
var kaesita = 0;
var risoku = 0;
for (var year=1; year <= 30; year++) {
for (var month=1; month <= 12; month++) {
kaesita = kaesita + 20;
from boxsdk import (OAuth2, Client)
def get_file_property(file_id):
oauth2 = OAuth2(
client_id="<YOUR CLIENT_ID>",
client_secret="<YOUR CLIENT_SECRET>",
access_token="<YOUR ACCESS_TOKEN>",
)
client = Client(oauth2)
@salexkidd
salexkidd / pipo.py
Created November 15, 2016 12:04
PC98 pipo
"""
PC98 PiPo!
======================
# setup and PiPo!
require pygame(sudo or virtualenv)
```
$ pip install pygame
```