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 <CommonCrypto/CommonDigest.h> | |
// ... | |
const char *unlockCode = "99999999"; | |
size_t unlockCodeSize = strlen(unlockCode); | |
unsigned char hashBytes[CC_SHA1_DIGEST_LENGTH]; | |
CC_SHA1(unlockCode, unlockCodeSize, hashBytes); | |
// ... |
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
- (NSData *)SHA1HashOfUTF8String { | |
const char *UTF8 = [self UTF8String]; | |
size_t UTF8Length = strlen(UTF8); | |
unsigned char hashedUTF8[CC_SHA1_DIGEST_LENGTH]; | |
CC_SHA1(UTF8, UTF8Length, hashedUTF8); | |
return [NSData dataWithBytes:hashedUTF8 length:sizeof(hashedUTF8)]; | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My Markdown Content</title> | |
<meta name="viewport" content="width=device-width" > | |
<style> | |
#status { |
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/python | |
from lxml import etree | |
from sys import stdin | |
t = etree.parse(stdin) | |
print etree.tostring(t, pretty_print=True) |
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
// 2008-09-22T13:57:31 | |
DateTime.UtcNow.ToString("s"); | |
// 2008-09-22T13:57:31.2311892-04:00 | |
DateTime.UtcNow.ToString("yyyy-MM-ddTHH\:mm\:ss.fffffffzzz"); | |
//2008-09-22T14:01:54.9571247Z | |
DateTime.UtcNow.ToString("o"); |
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
#!/bin/bash | |
# Displays man page as HTML page | |
# | |
# Requires the man2html utility, which can be installed on OS X with Homebrew (brew install man2html) | |
# See http://dcssrv1.oit.uci.edu/indiv/ehood/man2html.html for more info. | |
if [ -z "$1" ]; then | |
echo "usage: hman MANPAGE" | |
exit 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
#!/bin/bash | |
## Debugging: Show expanded commands before executing them | |
set -x | |
## Debugging: Exit with error on attempt to use unset variable | |
set -u | |
## Run commands in subshell | |
( /bin/foo; /bin/bar ) |
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
using System.Security.Cryptography; | |
using System.Text; | |
namespace Snippets | |
{ | |
public static class SHA1Util | |
{ | |
/// <summary> | |
/// Compute hash for string encoded as UTF8 | |
/// </summary> |
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
@implementation NSData (ZipFile) | |
- (BOOL)isZipFormatData { | |
// Zip files start with the bytes { 50, 4b, 03, 04 } | |
if (self.length < 4) | |
return NO; | |
unsigned char signature[4]; | |
[self getBytes:signature length:sizeof(signature)]; |
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
using System; | |
using System.Collections; | |
using System.Runtime.Remoting.Channels; | |
using System.Runtime.Remoting.Channels.Ipc; | |
using System.Runtime.Serialization.Formatters; | |
namespace MyLibrary | |
{ | |
/// <summary> | |
/// Utility methods to support .NET Remoting with IPC channels |