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
#include <tomcrypt.h> | |
#include <QFile> | |
#include <QDir> | |
// interface | |
class Crypto{ | |
public: | |
static int getKeySize(); | |
static void setKey(const char *key); |
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
tell application "Mail" | |
set theSubject to "Subject" -- the subject | |
set theContent to "Content" -- the content | |
set theAddress to "xxx@163.com" -- the receiver | |
set theSignatureName to "signature_name"-- the signature name | |
set theAttachmentFile to "Macintosh HD:Users:moligaloo:Downloads:attachment.pdf" -- the attachment path | |
set msg to make new outgoing message with properties {subject: theSubject, content: theContent, visible: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
# copied from https://stackoverflow.com/questions/2024805/ruby-send-json-request | |
require 'net/http' #net/https does not have to be required anymore | |
require 'json' | |
require 'uri' | |
uri = URI('https://your.secure-url.com') | |
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| | |
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') | |
request.body = {parameter: 'value'}.to_json |
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
+ (void)saveImage:(NSImage *)image atPath:(NSString *)path { | |
CGImageRef cgRef = [image CGImageForProposedRect:NULL | |
context:nil | |
hints:nil]; | |
NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc] initWithCGImage:cgRef]; | |
[newRep setSize:[image size]]; // if you want the same resolution | |
NSData *pngData = [newRep representationUsingType:NSPNGFileType properties:nil]; | |
[pngData writeToFile:path atomically:YES]; | |
[newRep autorelease]; | |
} |
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
obs := list("normal", "cold", "dizzy") | |
states := list("Healthy", "Fever") | |
start_p := Map with( | |
"Healthy", 0.6, | |
"Fever", 0.4 | |
) | |
trans_p := Map with( | |
"Healthy", Map with( | |
"Healthy", 0.7, | |
"Fever", 0.3 |
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
const obs = ["normal", "cold", "dizzy"] | |
const states = ["Healthy", "Fever"] | |
const start_p = { | |
Healthy: 0.6, | |
Fever: 0.4, | |
} | |
const trans_p = { | |
Healthy: { | |
Healthy: 0.7, |
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
obs = {'normal', 'cold', 'dizzy'} | |
states = {'Healthy', 'Fever'} | |
start_p = { | |
Healthy: 0.6, | |
Fever: 0.4 | |
} | |
trans_p = { | |
Healthy: { | |
Healthy: 0.7, |
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
class Main { | |
public static function main() { | |
trace(dichotomySqrt(2)); | |
trace(newtonSqrt(2)); | |
} | |
static function dichotomySqrt(x:Float):Float { | |
if (x < 0) { | |
return Math.NaN; | |
} |
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 | |
# Script to disable the iOS Simulator app from showing the "Do you want the application xxxx to accept incoming network connections?" pop-up every time the app is run | |
echo "> Enter password to temporarily shut firewall off" | |
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off | |
echo "> Add Xcode as a firewall exception" | |
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/MacOS/Xcode |
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
# plutil.pl 1.6 - implementation of binary/UTF-8 (text) XML conversion of plist files | |
# does not (yet) support OS X plutil command line syntax | |
# 1.0 - first public release | |
# 1.1 - added support for date Type 3; fixed real Type 2 | |
# 1.2 - fixed handling of empty arrays | |
# 1.3 - fixed handling of large strings and empty keys | |
# 1.4 - write utf8 in XML, convert as necessary on read | |
# 1.5 - read/write 8 byte integers and negative integers; handle special XML chars in dictionary keys | |
# - now requires Math::BigInt |
NewerOlder