How to delete all indexed data on Apache Solr?

curl http://localhost:8983/solr/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'

curl http://localhost:8983/solr/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'

Yorum bırakın

Filed under Solr

Persistent Data Storage with NSUserDefaults in Swift

If you need to store data between restarts of your iOS apps or occasions like that, then you probably need to use NSUserDefaults. Below you may see how to store data with NSUserDefaults. And as far as i understand, concept is named as Persistent Data Storage.

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // creating variables and initializing -> setObject(variable_value, variable_name)
        NSUserDefaults.standardUserDefaults().setObject("Timur", forKey: "name")
        NSUserDefaults.standardUserDefaults().setObject("Yildirim", forKey: "surname")
        NSUserDefaults.standardUserDefaults().setInteger(24, forKey: "age")
        NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isOnline")
        NSUserDefaults.standardUserDefaults().setFloat(3.14159, forKey: "pi")
        NSUserDefaults.standardUserDefaults().setDouble(2.71828, forKey: "euler")
        
        let blog = NSURL(string: "https://timuraykutyildirim.wordpress.com/");
        NSUserDefaults.standardUserDefaults().setURL(blog!, forKey: "myBlog")
        
        
        // sync initialized data into iOS
        NSUserDefaults.standardUserDefaults().synchronize()
        
        /* The exclamation mark at the end of this statement,
           if we would not have that, our output would be (Optional 24)
           so with ” ! ” we are telling xcode that the value does exist indeed. */
        println(NSUserDefaults.standardUserDefaults().objectForKey("age")!)
    }

Testing

Suppose you don’t have any iOS device when you want to test this code.  This is how you should do it:

  1. First, run the code as it is.
  2. Click “Stop Running” button on your Xcode
  3. Close your simulator (CMD+Q)
  4. Comment-in the decleration of your variable. In my case, it’s the line with  << setInteger(24, forKey: “age”) >>
  5. Run your application again. It’ll still print variable.
  6. Click “Stop Running” button on your Xcode
  7. Click (iOS Simulator) >> (Reset Content and Settings…) in your simulator’s File menu
  8. Close again your simulator (CMD+Q)
  9. Run your application one more time and this time it won’t work as it shouldn’t have in the first place.

Yorum bırakın

Filed under Swift

How to Make REST API Calls in Swift?

It’s plain and simple. You can do it like this:

 

var url : String = "http://00.00.000.000:99/ServiceName"
        var request : NSMutableURLRequest = NSMutableURLRequest()
        request.URL = NSURL(string: url)
        request.HTTPMethod = "GET"
        
        NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue(), completionHandler:{ (response:NSURLResponse!, data: NSData!, error: NSError!) -> Void in
            var error: AutoreleasingUnsafeMutablePointer<NSError?> = nil
            let jsonResult: NSDictionary! = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers, error: error) as? NSDictionary
            
            if (jsonResult != nil) {
                // process jsonResult
                println(jsonResult);
            } else {
                // couldn't load JSON, look at error
            }
            
            
        })

Yorum bırakın

Filed under Swift

iOS7 Controls – UISwitch

When we need to state a boolean object in iOS apps, UISwitch is best way to do it. It’s quiet simple. It’s whether ON or OFF. At the end of this article you may find public repository for demo of this control but for now let me define how i got up to that point.

First of all, fire up your Xcode and create a new Single View Application. I named is as iOS7UISwitchTutorial. Then you should fill out the Organization Name, Company Identifier. Then I chose iPhone in Devices area.

Now it’s time to design our interface. Go to Storyboard and design your screen like this: Okumaya devam et

Yorum bırakın

Filed under iOS App Development

How to Integrate Apache Nutch With Solr Search Engine?

One of my recent post, Bash programming for Crawling with cURL i mentioned i was assigned to collect and index mass data from internet and specific sources at work. cURL did job very well but i wanted to build something more compact and scalable. But since my fundamental approach is “Always avoid re-inventing the wheel” , i consulted senior colleague of mine and he suggested me to integrate Apache Foundation’s two beautiful project; Nutch (Crawler) and Solr(Search Engine).

There are several posts online claims to show how to integrate Nutch and Solr but i had a little bit of hard time to achieve this. So this is why i’m writing this post.

About Apache Nutch

Okumaya devam et

Yorum bırakın

Filed under Nutch, Solr

Xcode 6 iOS8 Error: Can’t find keyplane that supports type 8 for keyboard

Can’t find keyplane that supports type 8 for keyboard Wildcat-Landscape-QWERTY-Pad; using 3673479387_Wildcat-Alphabetic-Keyboard_Capital-Letters

If you see an error message like the one in above, you’re probably not able to see keyboard on your simulator while you run your app. Here’s the solution:

Run your app on simultor then go to iOS Simulator-> Hardware-> Keyboard -> Uncheck the Connect Hardware Keyboard Option

Yorum bırakın

Filed under Swift, Xcode

> Operator

> operatörü ile terminal komutlarınızı ihtiyaçlarınız doğrultusunda yönlendirebilirsiniz. Mesela az önce benim terminal geçmişimi kayıt altına almam gerekiyordu. Bunun için > operatörü ile şöyle bir çalışma yaptım:

Screenshot

Yorum bırakın

Filed under Ubuntu

Bash programming for Crawling with cURL

Currently i’m assigned to collect and index mass data from internet and specific sources at work. In order to achieve this, there is must-know concept called “Crawler“. After i talked with a senior colleague, i was done with whole concept and system architecture (or at least i knew more about which direction to go).

What is crawler?

Okumaya devam et

1 Yorum

Filed under Bash, Linux, Ubuntu

Xcode – fatal error: malformed or corrupted AST file

1

http://timuraykutyildirim.wordpress.com/2014/07/21/xcode-error-no-provisioned-ios-devices-are-available-with-a-compatible-ios-version/ adresindeki yazımın sonunda söz ettiğim bu hatayı düzeltmek için;

  1. Windows -> Organizer -> Projects
  2. Projennizi seçin ve “Derived Data”nın yanında bulunan delete butonuna tıklayın

2

Yorum bırakın

Filed under Xcode

Xcode error: No provisioned iOS devices are available with a compatible iOS version.

Bugün Xcode 5 kullanarak ve iOS 7.1′e yükseltilmiş bir chazı Mac’e bağlayarak uygulamamı çalıştırmak istediğimde karşıma çıktı bu hata. Hatta tam hata metni şöyle birşey:

Screen Shot 2014-07-21 at 10.57.54

Bu sorunu çözmek için Xcode’un File menüsünde şunları yaptım:

  1. Window -> Organizer
  2. Device sekmesine tıkla
  3. iOS device’ın üzerine tıkla ve sol kısımda bulunan “use for development” butonuna tıkla.

Sorun çözülmek şöyle bir dursun,  Xcode fatal error vermeye başladı. Gerçi bunda Xcode’un başlamadan önce istediği lüzumsuz güncelleştirmeleri yapmasına izin vermeminde payı var sanırım. Fakat o başka bir yazının konusu olmalı sanırım, hata şöyle birşey:

1

1 Yorum

Filed under Xcode