Skip to content

Instantly share code, notes, and snippets.

@sandeeplearner
sandeeplearner / index.html
Created October 28, 2015 09:58
Simple HTML page to generate multipart request
<html>
<body>
<h1>File Upload with Jersey</h1>
<form action="rest/update/profilePicture" method="post" enctype="multipart/form-data">
<p>
Select a file : <input type="file" name="profilePic" size="45" />
<input type="text" name="testingName"/>
</p>
<input type="submit" value="Upload It" />
@sandeeplearner
sandeeplearner / Codesnippet.java
Created October 28, 2015 10:01
Java REST API code snippet to accept Multipart/form-data
public class Snippet {
@POST
@Path("/profilePicture")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response profilePictureUpload(@FormDataParam("testingName") String fileName, @FormDataParam("profilePic") File inputfile)
{
//create upload folder path with user specified image name
String uploadFileName=profilePictureFolder+fileName;
//code to write file
@sandeeplearner
sandeeplearner / AndroidCodesnippet.java
Created October 28, 2015 10:05
Android Code snippet to make a simple multipart/form-data request
protected String doInBackground(String... params){
String attachmentName = "profilePic";
String crlf = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
String testName="sandeep.jpg";
try{
HttpURLConnection httpUrlConnection = null;
URL url = new URL("http://your_url_here.com/rest/update/profilePicture");
httpUrlConnection = (HttpURLConnection) url.openConnection();
@sandeeplearner
sandeeplearner / SBNotificationViewController.m
Created January 13, 2016 14:22
Shared manager of SBNotificationBar
+ (id)sharedManager {
static SBNotificationViewController *sharedMyManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}
@sandeeplearner
sandeeplearner / SBNotifi
Created January 13, 2016 14:27
init implementation
-(id)init{
self=[super init];
NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"SBNotificationBarView" owner:self options:nil];
UIView *mainView = [subviewArray objectAtIndex:0];
self.view = mainView;
keyWindow= [[SBCustomWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
keyWindow.windowLevel = UIWindowLevelAlert;
keyWindow.rootViewController = self;
@sandeeplearner
sandeeplearner / SBCustomWindow.m
Created January 13, 2016 16:24
SBCustomWindowCode
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
if(CGRectContainsPoint(self.rootViewController.view.frame, point)){
[(SBNotificationViewController *)self.rootViewController checkIfNotificationBarTappedWithPoint:point andEvent:event];
return true;
}
else{
return false;
}
}
let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate
appDelegate?.managedObjectContext.performBlock({
let person = NSEntityDescription.insertNewObjectForEntityForName("Person", inManagedObjectContext: (appDelegate?.managedObjectContext)!) as! Person
person.name = "Sandeep"
person.age = NSNumber(integer: Int(26))
person.nickname = "Sandeep"
person.phone = "1234567890"
try! appDelegate?.managedObjectContext.save()
self.dismissViewControllerAnimated(true, completion: nil)
})
target 'EncryptedCoredata' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for EncryptedCoredata
pod 'RNCryptor', '~> 4.0.0-beta'
target 'EncryptedCoredataTests' do
inherit! :search_paths
# Pods for testing
import UIKit
import RNCryptor
class EncryptedStringTransformer : NSValueTransformer {
let password = "S@ndeepHere123"
override func transformedValue(value: AnyObject?) -> AnyObject? {
guard let passedValue = value else {
return nil
}
do {
try coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil)
} catch {
// Report any error we got.
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error as NSError
let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)