Skip to content

Instantly share code, notes, and snippets.

View nanzhipro's full-sized avatar

南知 nanzhipro

View GitHub Profile
@nanzhipro
nanzhipro / WeakSingleton
Created August 3, 2017 03:33 — forked from antoniocasero/WeakSingleton
Weak Singleton
+ (id)sharedInstance
{
static __weak ASingletonClass *instance;
ASingletonClass *strongInstance = instance;
@synchronized(self) {
if (strongInstance == nil) {
strongInstance = [[[self class] alloc] init];
instance = strongInstance;
}
}
"""
Python 3
"""
import os
import glob
import argparse
import cv2
from PIL import Image
import numpy as np
@nanzhipro
nanzhipro / face_checker_cv_notalk.py
Created January 24, 2018 02:09 — forked from PonDad/face_checker_cv_notalk.py
Raspberry Pi 深層学習でリアルタイム顔認識(Keras・Open CV)
import face_keras as face
import sys, os
from keras.preprocessing.image import load_img, img_to_array
import numpy as np
import cv2
import time
cascade_path = "haarcascade_frontalface_alt.xml"
cascade = cv2.CascadeClassifier(cascade_path)
cam = cv2.VideoCapture(0)
@nanzhipro
nanzhipro / machine.js
Created August 20, 2019 06:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nanzhipro
nanzhipro / pfctl-cheatsheet.txt
Created January 5, 2022 03:52 — forked from johnbianchi/pfctl-cheatsheet.txt
pfctl cheat sheet
#### General PFCTL Commands ####
$ pfctl -d disable # packet-filtering
$ pfctl -e enable # packet-filtering
$ pfctl -q # run quiet
$ pfctl -v -v # run even more verbose
#### Loading PF Rules ####
$ pfctl -f /etc/pf.conf # load /etc/pf.conf
$ pfctl -n -f /etc/pf.conf # parse /etc/pf.conf, but dont load it
$ pfctl -R -f /etc/pf.conf # load only the FILTER rules
$ pfctl -N -f /etc/pf.conf # load only the NAT rules
@nanzhipro
nanzhipro / ScreenCapture.m
Created February 4, 2022 04:52 — forked from chinmaygarde/ScreenCapture.m
Mac OSX Screen Capture
CGImageRef imageRef = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionAll, kCGNullWindowID, kCGWindowImageDefault);
CFMutableDataRef dataRef = CFDataCreateMutable(kCFAllocatorDefault, 0);
CGImageDestinationRef dest = CGImageDestinationCreateWithData(dataRef, kUTTypePNG, 1, NULL);
CGImageDestinationAddImage(dest, imageRef, NULL);
CGImageDestinationFinalize(dest);
CFRelease(dest);
CGImageRelease(imageRef);
@nanzhipro
nanzhipro / spotlight.factor
Created February 8, 2022 05:50 — forked from cwalston/spotlight.factor
Searching on OS X via Spotlight MetaData index, & managing indexing from Factor
! (C) 2013 Charles Alston.
USING: accessors arrays byte-arrays fry google.search io
io.encodings.utf8 io.launcher kernel locals make namespaces
sequences simple-tokenizer splitting strings unicode.categories
webbrowser wordtimer ;
IN: spotlight
! *** SEARCHING ON OS X VIA SPOTLIGHT METADATA INDEX, & MANAGING INDEXING FROM FACTOR ***
! *** MAC OS X 10.6.8 & LATER: IMPLEMENTING mdfind, mdls, mdutil, mdimport ***
! mdfind, mdls, mdutil, mdimport TAKE A QUERY ON THE STACK & RETURN A SEQUENCE OF RESULT STRINGS
@nanzhipro
nanzhipro / runAsUser.sh
Created February 16, 2022 08:54 — forked from scriptingosx/runAsUser.sh
template script for macOS which can run a command as the currently logged in user. https://scriptingosx.com/2020/08/running-a-command-as-another-user/
#!/bin/sh
# template script for running a command as user
# The presumption is that this script will be executed as root from a launch daemon
# or from some management agent. To execute a single command as the current user
# you can use the `runAsUser` function below.
# by Armin Briegel - Scripting OS X
#
@nanzhipro
nanzhipro / EndpointSecurityDemo.m
Created March 2, 2022 00:42 — forked from abjurato/EndpointSecurityDemo.m
A demo of using Apple's new EndpointSecurity framework - tested on macOS Catalina 10.15 (19A583)
//
// main.m
// EndpointSecurityDemo
//
// Created by Omar Ikram on 17/06/2019 - Catalina 10.15 Beta 1 (19A471t)
// Updated by Omar Ikram on 15/08/2019 - Catalina 10.15 Beta 5 (19A526h)
// Updated by Omar Ikram on 01/12/2019 - Catalina 10.15 (19A583)
//
#import <Foundation/Foundation.h>
@nanzhipro
nanzhipro / EndpointSecurityDemo.m
Created March 2, 2022 00:43 — forked from Omar-Ikram/EndpointSecurityDemo.m
A demo of using Apple's EndpointSecurity framework - tested on macOS Monterey 12.2.1 (21D62)
//
// main.m
// EndpointSecurityDemo
//
// Created by Omar Ikram on 17/06/2019 - macOS Catalina 10.15 Beta 1 (19A471t)
// Updated by Omar Ikram on 15/08/2019 - macOS Catalina 10.15 Beta 5 (19A526h)
// Updated by Omar Ikram on 01/12/2019 - macOS Catalina 10.15 (19A583)
// Updated by Omar Ikram on 31/01/2021 - macOS Big Sur 11.1 (20C69)
// Updated by Omar Ikram on 07/05/2021 - macOS Big Sur 11.3.1 (20E241)
// Updated by Omar Ikram on 04/07/2021 - macOS Monterey 12 Beta 2 (21A5268h)