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
# Lil loading tool for JWCC: JSON With Commas and Comments. | |
# See docstrings for loads() and jwcc2json() for more info. | |
# Public domain. | |
import json | |
import re | |
_INTERESTING_B = re.compile(rb''' | |
\] # array end | |
| \} # object end | |
| (?<! \\)" # string start |
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
// Public domain - https://gist.github.com/nolanw/dff7cc5d5570b030d6ba385698348b7c | |
import Foundation | |
extension URLRequest { | |
/** | |
Configures the URL request for `multipart/form-data`. The request's `httpBody` is set, and a value is set for the HTTP header field `Content-Type`. | |
- Parameter parameters: The form data to set. |
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
// Public domain - https://gist.github.com/nolanw/14b277903a2ba446f75202a6bfd55977 | |
import Foundation | |
extension URLRequest { | |
/** | |
Configures the URL request for `application/x-www-form-urlencoded` data. The request's `httpBody` is set, and values are set for HTTP header fields `Content-Type` and `Content-Length`. | |
- Parameter queryItems: The (name, value) pairs to encode and set as the request's body. |
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 python | |
from __future__ import print_function | |
import json | |
from io import BytesIO | |
import logging | |
import os | |
import sys | |
try: | |
from urllib.request import Request, urlopen # py3 | |
from urllib.parse import quote |
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 swift | |
// Swift 3.0 | |
import Foundation | |
func main() -> Int32 { | |
if CommandLine.arguments.count < 2 { | |
print("") | |
print("Usage: \(CommandLine.arguments[0]) (path_to_pbxproj | path_to_xcodeproj)") |
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 Foundation | |
/// A number formatter that usefully implements `attributedString(for:withDefaultAttributes:)`, which iOS's NumberFormatter does not. | |
final class AttributedNumberFormatter: NumberFormatter { | |
override func attributedString(for obj: Any, withDefaultAttributes defaultAttributes: [NSAttributedString.Key : Any]? = nil) -> NSAttributedString? { | |
guard | |
let number = obj as? NSNumber, | |
let plain = string(from: number) | |
else { return nil } |
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
// clang -framework Foundation isequal.m | |
#include <mach/mach_time.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#import <Foundation/Foundation.h> | |
// Convert from mach time to seconds (gets set in main() below). | |
double ticksToNanos = 0; | |
// Run some code many times, timing how long it took, and announce the average |
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 | |
FSCRIPT_PATH = "/Library/Frameworks/FScript.framework" | |
if ARGV.empty? | |
puts "Usage: #{$0} process_name" | |
exit | |
end | |
GDB = IO.popen("gdb", 'w') |
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 | |
def wrap text, sigil, indent | |
text = text.map do |line| | |
line.match(/^\s*\S (.*)$/)[1] | |
end.join ' ' | |
lines = [] | |
while text and not text.empty? | |
cut = [text.length, 78 - indent].min | |
if cut < text.length and text[cut, 1] != ' ' |
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
static int IsC99() | |
{ | |
return (2//* */2 | |
== 2); | |
} |
NewerOlder