SCP (Secure Copy) through SSH

Copying file/folder to host:

scp SourceFile user@host:directory/TargetFile
scp -r /local/folder/directory/ user@host:/target/folder/directory

Copying file/folder from host:

scp user@host:directory/SourceFile TargetFile
scp -r user@host:directory/SourceFolder TargetFolder

Note that if the remote host uses a port other than the default of 22, it can be specified in the command. For example, copying a file from host:

scp -P 2222 user@host:directory/SourceFile TargetFile

Yorum bırakın

Filed under Linux, Mac OS X

How to log all input/output in a terminal session?

Start logger : script myTerminalSession.log

Stop logger : exit

Yorum bırakın

Filed under Ubuntu

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