This file contains hidden or 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
id uri = [NSURL URLWithString: uriString]; | |
id request = [NSMutableURLRequest requestWithURL:uri]; | |
[request | |
setValue:[NSString stringWithFormat:@"Basic %@", encodedIdAndPassword] | |
forHTTPHeaderField:@"Authorization" | |
]; |
This file contains hidden or 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
-(NSMutableData*) createHTTPPostBodyWithParameters:(NSDictionary*)params boundary:(NSString*)boundary | |
{ | |
NSMutableData *paramsData = [NSMutableData new]; | |
NSString *enter = @"\r\n"; | |
for(id key in params) { | |
[paramsData appendData:[[NSString stringWithFormat:@"--%@%@", boundary, enter] dataUsingEncoding:NSUTF8StringEncoding]]; | |
[paramsData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"", key] dataUsingEncoding:NSUTF8StringEncoding]]; | |
// File |
This file contains hidden or 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
-(NSMutableData*) createHTTPPostBodyWithParameters:(NSDictionary*)params boundary:(NSString*)boundary | |
{ | |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | |
NSMutableArray *paramsArray = [NSMutableArray array]; | |
NSMutableData *paramsData = [NSMutableData new]; | |
NSString *enter = @"\r\n"; | |
for(id key in params) { | |
[paramsArray addObject:[NSString stringWithFormat:@"--%@%@", boundary, enter]]; |
This file contains hidden or 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
def build_multipart_post_data(params, boundary) | |
enter = "\r\n" | |
data = '' | |
params.each do |k,v| | |
next if v.nil? | |
data << '--' + boundary + enter | |
data << %Q[Content-Disposition: form-data; name="#{k.to_s}"] | |
if k.to_s == 'file' |
This file contains hidden or 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
def build_multipart_post_data(params, boundary) | |
enter = "\r\n" | |
data = '' | |
params.each do |k,v| | |
next if v.nil? | |
data << '--' + boundary + enter | |
data << %Q[Content-Disposition: form-data; name="#{k.to_s}"] | |
if k.to_s == 'file' |
This file contains hidden or 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
## % ruby -rnet/http twitpost.rb | |
res = Net::HTTP.post_form(URI.parse("http://USERNAME:[email protected]/statuses/update.xml"), :status => 'おっぱい', :source => 'oppai') | |
puts 'update was failed' unless res.instance_of? Net::HTTPOK |
This file contains hidden or 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/Foundation.h" | |
#include <libxml/HTMLparser.h> | |
#include <libxml/HTMLtree.h> | |
#include <libxml/xpath.h> | |
@interface XPathEvaluator : NSObject | |
+(NSArray*)arrayWithXPathQuery:(NSString*)query fromHTML:(NSString*)html; | |
@end | |
@implementation XPathEvaluator |
This file contains hidden or 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/Foundation.h> | |
#define TAPE_MAX_WIDTH 1 | |
@interface BrainFxck : NSObject | |
{ | |
const char *code; | |
unsigned char *tape; | |
unsigned int position; | |
unsigned int tape_width; |
This file contains hidden or 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
// | |
// ImagePicker で選択された画像を保存する | |
// | |
// | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info | |
{ | |
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; | |
// 画像を保存(バンドルのルートディレクトリ) | |
NSData *jpeg = [[NSData alloc] initWithData:UIImageJPEGRepresentation(image, 100)]; |
This file contains hidden or 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
// vim: fileencoding=utf-8 expandtab tabstop=2 shiftwidth=2 : | |
// | |
// vmstatics.c | |
// | |
// % clang -Wall -o vmstatics vmstatics.c | |
// % ./vmstatics | |
// active 1627869184 | |
// inactive 1990959104 | |
// wired 1616474112 | |
// speculative 1243693056 |
OlderNewer