title | date | categories | author | tags | ||
---|---|---|---|---|---|---|
接码平台 |
2019-12-12 |
article |
Kamchan |
|
This file contains 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 wave | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-i", "--input", required=True, help="input pcm file") | |
parser.add_argument("-o", "--output", required=False, help="output wav file") | |
parser.add_argument("-s", "--sample_rate", type=int, default=16000, help="sample rate") | |
parser.add_argument("-c", "--num_channels", type=int, default=1, help="number of channels") | |
parser.add_argument("-w", "--sample_width", type=int, default=2, help="sample width") | |
args = parser.parse_args() |
This file contains 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 | |
# -*- coding: utf-8 -*- | |
import ctypes | |
from ctypes import wintypes | |
class SYSTEM_POWER_STATUS(ctypes.Structure): | |
_fields_ = [ | |
('ACLineStatus', wintypes.BYTE), | |
('BatteryFlag', wintypes.BYTE), |
This file contains 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
//Both implementations thanks to https://useyourloaf.com/blog/how-to-percent-encode-a-url-string/ | |
//Upgraded/cleaned up for Swift 4 | |
Extension String { | |
func percentEncodedForRFC3986() -> String? { | |
let unreserved = "-._~/?" | |
var allowed = CharacterSet.alphanumerics | |
allowed.insert(charactersIn: unreserved) | |
return self.addingPercentEncoding(withAllowedCharacters: allowed) | |
} |
This file contains 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
bash -c 'set -o pipefail && (git archive [email protected]:annidy/ObjCSameCodeFinder.git --format=tar master | tar -x)' |
This file contains 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
//cc -Wextra -o build/dump-header-map dump-header-map.c | |
// see: https://github.com/llvm-mirror/clang/blob/release_40/include/clang/Lex/HeaderMapTypes.h | |
// https://github.com/llvm-mirror/clang/blob/release_40/include/clang/Lex/HeaderMap.h// https://github.com/llvm-mirror/clang/blob/release_40/lib/Lex/HeaderMap.cpp | |
// This is basically dump() from there. | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sysexits.h> | |
#include <err.h> |
This file contains 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 ruby | |
# This script currently only works if you have your derived data in the default location. | |
# Get the workspace name to search for, or exit with code 1 if no value in envariable | |
xcodeWorkspacePath = ENV["XcodeWorkspacePath"] || exit(1) | |
projectName = xcodeWorkspacePath[%r{/(\w+)\.xcodeproj}, 1] | |
#Get the folders in derived data that could match the workspace | |
derived_data = File.expand_path("~/Library/Developer/Xcode/DerivedData") | |
# Glob out the files matching our project |
This file contains 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
//Copyright (c) 2018 Michael Eisel. All rights reserved. | |
#import "CLRCallRecorder.h" | |
#import <dlfcn.h> | |
#import <libkern/OSAtomicQueue.h> | |
#import <pthread.h> | |
typedef struct { | |
void *ptr; | |
NSInteger number; |
This file contains 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> | |
@implementation NSAssertionHandler (Disable) | |
+ (void)initialize { | |
[self swizzMethod:@selector(handleFailureInMethod:object:file:lineNumber:description:) to:@selector(swizz_handleFailureInMethod:object:file:lineNumber:description:)]; | |
[self swizzMethod:@selector(handleFailureInFunction:file:lineNumber:description:) to:@selector(swizz_handleFailureInFunction:file:lineNumber:description:)]; | |
} | |
+ (void)swizzMethod:(SEL)originalSelector to:(SEL)swizzledSelector { |
NewerOlder