How to Write to NTFS Drives in OS X

First of all, chmod is not the answer.

  1. sudo nano /etc/fstab
  2. Write “LABEL=drivename none ntfs rw,auto,nobrowse” in fstab
  3. kntrl-O & kntrl-X shotcuts will write and save your changes
  4. Unmount your drive from Mac
  5. Unplug your drive from Mac
  6. Plug your drive back in
  7. Within Finder’s menu bar, click “Go to Folder”
  8. Type /Volumes in “Go to Folder” screen. This will display all drives whether they’re available or not
  9. Drag your drive into Favourites, left of current Finder screen.

This is how you do it.

Yorum bırakın

Filed under Mac OS X

Cannot start PyCharm No JDK found

If have an error message like “ERROR: Cannot start PyCharm No JDK found. Please validate either PYCHARM_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.” while trying to install pycharm on ubuntu, this how you fix it:

 sudo apt-get purge openjdk*
 sudo add-apt-repository ppa:webupd8team/java
 sudo apt-get update
 sudo apt-get install oracle-java7-installer

Yorum bırakın

Filed under Python, Ubuntu

How to Run Bash Scripts within Python?

There are 2 different approaches:

import os
os.system('echo "hello"')

import subprocess"./", shell=True)

Some say first approach is deprecated but i think they haven’t faced any problem when all you need is a single line command to run within different parameters. So, in my opinion each one has it’s own advantage.

Yorum bırakın

Filed under Python

How to split text files into small subsets with Python?

This is how you do it:

lines_per_file = 500
smallfile = None
with open('processedTotal.txt') as bigfile:
   for lineno, line in enumerate(bigfile):
      if lineno % lines_per_file == 0:
         if smallfile:
         small_filename = 'set_{}.txt'.format(lineno + lines_per_file)
         smallfile = open(small_filename, "w")
   if smallfile:

Yorum bırakın

Filed under Python

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() {
        // 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: "");
        NSUserDefaults.standardUserDefaults().setURL(blog!, forKey: "myBlog")
        // sync initialized data into iOS
        /* 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. */


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 = ""
        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
            } 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