Rectangle 27 1

How to put images in your Gist url:

  • upload your image to a place like imgur.com for free, then get the hot-link.
  • Add a file and give it a markdown extension .md and use markdown image syntax:
![alt text here](https://URL)

github - How do you upload images to a gist? - Stack Overflow

github gist
Rectangle 27 1

How to put images in your Gist url:

  • upload your image to a place like imgur.com for free, then get the hot-link.
  • Add a file and give it a markdown extension .md and use markdown image syntax:
![alt text here](https://URL)

github - How do you upload images to a gist? - Stack Overflow

github gist
Rectangle 27 4

Go to https://github.com/new/import and put in the URL of your gist and a name for your new repo.

  • Many people don't realize that gist commits may have commit messages that you cannot see with the web interface. The gist above has 2 very decrsiptive commit messages that I commited on my local clone and pushed out. They are hidden from the gist web interface, but show up in clones and also new repos created using this import feature.
  • CON: In spite of #2, it shows only 1 contributor (which is myself).
  • CON: Even though my gist shows "forked from nboubakr/subnet.py", this new/imported github repo does not show that it is a fork of anything (not nboubakr's gist nor my gist)

This works very well and I really appreciate the PROs. The cons are not enough to make me think that some other method would be better.

I will use this extensively in the future because I often create a gist that answers some Stack Overflow question. Then I expand upon it and realize it should be a full repo. Not that I think my work is of great significance, but because I think my commit messages are worth sharing. And this is because I am lazy and tend to not want to create documentation that just repeats what i have already said in commit messages.

Nice (+1) Seems to be a good potential solution

Very cool thanks for such deep study and sharing the pros and cons!

Fork Gist to Repo on GitHub - Stack Overflow

github fork gist git-fork
Rectangle 27 30

Here's a gist I put together. I was wondering the same and this helped improve my understanding. Open this up in an Xcode Playground to see what's going on.

protocol YelpRequestDelegate {
    func getYelpData() -> AnyObject
    func processYelpData(data: NSData) -> NSData
}

class YelpAPI {
    var delegate: YelpRequestDelegate?

    func getData() {
        println("data being retrieved...")
        let data: AnyObject? = delegate?.getYelpData()
    }

    func processYelpData(data: NSData) {
        println("data being processed...")
        let data = delegate?.processYelpData(data)
    }
}

class Controller: YelpRequestDelegate {
    init() {
        var yelpAPI = YelpAPI()
        yelpAPI.delegate = self
        yelpAPI.getData()
    }
    func getYelpData() -> AnyObject {
        println("getYelpData called")
        return NSData()
    }
    func processYelpData(data: NSData) -> NSData {
        println("processYelpData called")
        return NSData()
    }
}

var controller = Controller()

@SeeMeCode Hi, It was good example firstly, but i still have an issue. How can i make my any UIViewController class to conform delegate we made? Are they have to be declared in one swift file? Any help will mean a lot.

@Faruk It's been awhile since I posted this, but I think what you're asking should be pretty simple (If I'm misunderstanding, I apologize). Just add the delegate to your UIViewController after the colon. So something like class ViewController : UIViewController NameOfDelegate.

a.swift
b.swift

Delegates in swift? - Stack Overflow

delegates swift delegation
Rectangle 27 30

Here's a gist I put together. I was wondering the same and this helped improve my understanding. Open this up in an Xcode Playground to see what's going on.

protocol YelpRequestDelegate {
    func getYelpData() -> AnyObject
    func processYelpData(data: NSData) -> NSData
}

class YelpAPI {
    var delegate: YelpRequestDelegate?

    func getData() {
        println("data being retrieved...")
        let data: AnyObject? = delegate?.getYelpData()
    }

    func processYelpData(data: NSData) {
        println("data being processed...")
        let data = delegate?.processYelpData(data)
    }
}

class Controller: YelpRequestDelegate {
    init() {
        var yelpAPI = YelpAPI()
        yelpAPI.delegate = self
        yelpAPI.getData()
    }
    func getYelpData() -> AnyObject {
        println("getYelpData called")
        return NSData()
    }
    func processYelpData(data: NSData) -> NSData {
        println("processYelpData called")
        return NSData()
    }
}

var controller = Controller()

@SeeMeCode Hi, It was good example firstly, but i still have an issue. How can i make my any UIViewController class to conform delegate we made? Are they have to be declared in one swift file? Any help will mean a lot.

@Faruk It's been awhile since I posted this, but I think what you're asking should be pretty simple (If I'm misunderstanding, I apologize). Just add the delegate to your UIViewController after the colon. So something like class ViewController : UIViewController NameOfDelegate.

a.swift
b.swift

Delegates in swift? - Stack Overflow

delegates swift delegation
Rectangle 27 2

For GitLab users I've put up a gist on how I migrated from SVN here:

svn.domain.com.au
  • SVN is accessible via http (other protocols should work).
git.domain.com.au
  • A group is created with the namespace dev-team.
  • At least one user account is created, added to the group, and has an SSH key for the account being used for the migration (test using ssh git@git.domain.com.au).
  • The project favourite-project is created in the dev-team namespace.
  • The file users.txt contains the relevant user details, one user per line, of the form username = First Last <address@domain.com.au>, where username is the username given in SVN logs. (See first link in References section for details, in particular answer by user Casey).
bash
git svn clone --stdlayout --no-metadata -A users.txt 
http://svn.domain.com.au/svn/repository/favourite-project
cd favourite-project
git remote add gitlab git@git.domain.com.au:dev-team/favourite-project.git
git push --set-upstream gitlab master

That's it! Reload the project page in GitLab web UI and you will see all commits and files now listed.

  • If there are unknown users, the git svn clone command will stop, in which case, update users.txt, cd favourite-project and git svn fetch will continue from where it stopped.
  • The standard trunk-tags-branches layout for SVN repository is required.
  • The SVN URL given to the git svn clone command stops at the level immediately above trunk/, tags/ and branches/.
  • The git svn clone command produces a lot of output, including some warnings at the top; I ignored the warnings.

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

I disagree. The linked content might change, and the content duplicated here will not be updated, and therefore might be out of date (and in fact I believe it has changed since I originally posted this answer). The guidelines only say to include some relevant context for a link, which I did -- the actual question was answered wholesale by the link. Copying the whole linked resource here is not required or necessary. Was I downvoted for this?!

How to migrate SVN repository with history to a new Git repository? - ...

svn git version-control git-svn
Rectangle 27 2

For GitLab users I've put up a gist on how I migrated from SVN here:

svn.domain.com.au
  • SVN is accessible via http (other protocols should work).
git.domain.com.au
  • A group is created with the namespace dev-team.
  • At least one user account is created, added to the group, and has an SSH key for the account being used for the migration (test using ssh git@git.domain.com.au).
  • The project favourite-project is created in the dev-team namespace.
  • The file users.txt contains the relevant user details, one user per line, of the form username = First Last <address@domain.com.au>, where username is the username given in SVN logs. (See first link in References section for details, in particular answer by user Casey).
bash
git svn clone --stdlayout --no-metadata -A users.txt 
http://svn.domain.com.au/svn/repository/favourite-project
cd favourite-project
git remote add gitlab git@git.domain.com.au:dev-team/favourite-project.git
git push --set-upstream gitlab master

That's it! Reload the project page in GitLab web UI and you will see all commits and files now listed.

  • If there are unknown users, the git svn clone command will stop, in which case, update users.txt, cd favourite-project and git svn fetch will continue from where it stopped.
  • The standard trunk-tags-branches layout for SVN repository is required.
  • The SVN URL given to the git svn clone command stops at the level immediately above trunk/, tags/ and branches/.
  • The git svn clone command produces a lot of output, including some warnings at the top; I ignored the warnings.

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

I disagree. The linked content might change, and the content duplicated here will not be updated, and therefore might be out of date (and in fact I believe it has changed since I originally posted this answer). The guidelines only say to include some relevant context for a link, which I did -- the actual question was answered wholesale by the link. Copying the whole linked resource here is not required or necessary. Was I downvoted for this?!

How to migrate SVN repository with history to a new Git repository? - ...

svn git version-control git-svn
Rectangle 27 2

For GitLab users I've put up a gist on how I migrated from SVN here:

svn.domain.com.au
  • SVN is accessible via http (other protocols should work).
git.domain.com.au
  • A group is created with the namespace dev-team.
  • At least one user account is created, added to the group, and has an SSH key for the account being used for the migration (test using ssh git@git.domain.com.au).
  • The project favourite-project is created in the dev-team namespace.
  • The file users.txt contains the relevant user details, one user per line, of the form username = First Last <address@domain.com.au>, where username is the username given in SVN logs. (See first link in References section for details, in particular answer by user Casey).
bash
git svn clone --stdlayout --no-metadata -A users.txt 
http://svn.domain.com.au/svn/repository/favourite-project
cd favourite-project
git remote add gitlab git@git.domain.com.au:dev-team/favourite-project.git
git push --set-upstream gitlab master

That's it! Reload the project page in GitLab web UI and you will see all commits and files now listed.

  • If there are unknown users, the git svn clone command will stop, in which case, update users.txt, cd favourite-project and git svn fetch will continue from where it stopped.
  • The standard trunk-tags-branches layout for SVN repository is required.
  • The SVN URL given to the git svn clone command stops at the level immediately above trunk/, tags/ and branches/.
  • The git svn clone command produces a lot of output, including some warnings at the top; I ignored the warnings.

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

I disagree. The linked content might change, and the content duplicated here will not be updated, and therefore might be out of date (and in fact I believe it has changed since I originally posted this answer). The guidelines only say to include some relevant context for a link, which I did -- the actual question was answered wholesale by the link. Copying the whole linked resource here is not required or necessary. Was I downvoted for this?!

How do I migrate an SVN repository with history to a new Git repositor...

svn git version-control git-svn
Rectangle 27 2

For GitLab users I've put up a gist on how I migrated from SVN here:

svn.domain.com.au
  • SVN is accessible via http (other protocols should work).
git.domain.com.au
  • A group is created with the namespace dev-team.
  • At least one user account is created, added to the group, and has an SSH key for the account being used for the migration (test using ssh git@git.domain.com.au).
  • The project favourite-project is created in the dev-team namespace.
  • The file users.txt contains the relevant user details, one user per line, of the form username = First Last <address@domain.com.au>, where username is the username given in SVN logs. (See first link in References section for details, in particular answer by user Casey).
bash
git svn clone --stdlayout --no-metadata -A users.txt 
http://svn.domain.com.au/svn/repository/favourite-project
cd favourite-project
git remote add gitlab git@git.domain.com.au:dev-team/favourite-project.git
git push --set-upstream gitlab master

That's it! Reload the project page in GitLab web UI and you will see all commits and files now listed.

  • If there are unknown users, the git svn clone command will stop, in which case, update users.txt, cd favourite-project and git svn fetch will continue from where it stopped.
  • The standard trunk-tags-branches layout for SVN repository is required.
  • The SVN URL given to the git svn clone command stops at the level immediately above trunk/, tags/ and branches/.
  • The git svn clone command produces a lot of output, including some warnings at the top; I ignored the warnings.

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

I disagree. The linked content might change, and the content duplicated here will not be updated, and therefore might be out of date (and in fact I believe it has changed since I originally posted this answer). The guidelines only say to include some relevant context for a link, which I did -- the actual question was answered wholesale by the link. Copying the whole linked resource here is not required or necessary. Was I downvoted for this?!

How to migrate SVN repository with history to a new Git repository? - ...

svn git version-control git-svn
Rectangle 27 2

For GitLab users I've put up a gist on how I migrated from SVN here:

svn.domain.com.au
  • SVN is accessible via http (other protocols should work).
git.domain.com.au
  • A group is created with the namespace dev-team.
  • At least one user account is created, added to the group, and has an SSH key for the account being used for the migration (test using ssh git@git.domain.com.au).
  • The project favourite-project is created in the dev-team namespace.
  • The file users.txt contains the relevant user details, one user per line, of the form username = First Last <address@domain.com.au>, where username is the username given in SVN logs. (See first link in References section for details, in particular answer by user Casey).
bash
git svn clone --stdlayout --no-metadata -A users.txt 
http://svn.domain.com.au/svn/repository/favourite-project
cd favourite-project
git remote add gitlab git@git.domain.com.au:dev-team/favourite-project.git
git push --set-upstream gitlab master

That's it! Reload the project page in GitLab web UI and you will see all commits and files now listed.

  • If there are unknown users, the git svn clone command will stop, in which case, update users.txt, cd favourite-project and git svn fetch will continue from where it stopped.
  • The standard trunk-tags-branches layout for SVN repository is required.
  • The SVN URL given to the git svn clone command stops at the level immediately above trunk/, tags/ and branches/.
  • The git svn clone command produces a lot of output, including some warnings at the top; I ignored the warnings.

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

I disagree. The linked content might change, and the content duplicated here will not be updated, and therefore might be out of date (and in fact I believe it has changed since I originally posted this answer). The guidelines only say to include some relevant context for a link, which I did -- the actual question was answered wholesale by the link. Copying the whole linked resource here is not required or necessary. Was I downvoted for this?!

How to migrate SVN repository with history to a new Git repository? - ...

svn git version-control git-svn
Rectangle 27 1

You can get the individual files in the Gist (or download the Gist as an ZIP and extract) and put them in your source code folder.

Then you will be able to import them as modules in your own scripts:

import analytic_wfm as AW
AW.ACV_A6( ... )

import peakdetect as PK
PK.peakdetect_parabola( ... )

Where you say source code folder, you mean where my .py script is that I am running?

But everytime I want to use this function, I have to put this script in the same folder? Isn't there a global folder where I can store it?

@renegade You can put it in a directory which is present in the environment variable PYTHONPATH.

@renegade on Ubuntu, use sudo to move the scripts to /usr/local/lib/python2.7/dist-packages after downloading them. They'll then be available for import into any Python 2 program.

python - How do I install a package from GitHub gist? - Stack Overflow

python
Rectangle 27 1

You can get the individual files in the Gist (or download the Gist as an ZIP and extract) and put them in your source code folder.

Then you will be able to import them as modules in your own scripts:

import analytic_wfm as AW
AW.ACV_A6( ... )

import peakdetect as PK
PK.peakdetect_parabola( ... )

Where you say source code folder, you mean where my .py script is that I am running?

But everytime I want to use this function, I have to put this script in the same folder? Isn't there a global folder where I can store it?

@renegade You can put it in a directory which is present in the environment variable PYTHONPATH.

@renegade on Ubuntu, use sudo to move the scripts to /usr/local/lib/python2.7/dist-packages after downloading them. They'll then be available for import into any Python 2 program.

python - How do I install a package from GitHub gist? - Stack Overflow

python
Rectangle 27 1

CClauss got the answer and put it in the comment section of the gist linked above. I take no credit.

mkdir -p
# Slash '/' is hardcoded because ftp always uses slash
def mk_each_dir(sftp, inRemoteDir):
    currentDir = '/'
    for dirElement in inRemoteDir.split('/'):
        if dirElement:
            currentDir += dirElement + '/'
            print('Try to mkdir on :' + currentDir)
            try:
                sftp.mkdir(currentDir)
            except:
                pass # fail silently if remote directory already exists

# Set Variables
fileName = "temp.png"
remotePath = "/home/userZ/Dropbox/uploads/"
datePath = "year/month/"
remoteDirPath =  remotePath + datePath
mk_each_dir(sftp, remoteDirPath)
sftp.chdir(remoteDirPath)
remoteFilePath =  remoteDirPath + fileName

SFTP Upload via Python and Pythonista with Paramiko. Can't create dire...

python sftp paramiko mkdir pythonista
Rectangle 27 6

As others have noted, requests is a fantastic library. However, if you are in a situation where requests cannot be used (say an ansible module development or similar), there is another way, as demonstrated by the author of this gist:

import urllib2

class MethodRequest(urllib2.Request):
    def __init__(self, *args, **kwargs):
        if 'method' in kwargs:
            self._method = kwargs['method']
            del kwargs['method']
        else:
            self._method = None
        return urllib2.Request.__init__(self, *args, **kwargs)

    def get_method(self, *args, **kwargs):
        if self._method is not None:
            return self._method
        return urllib2.Request.get_method(self, *args, **kwargs)
>>> req = MethodRequest(url, method='PUT')

Doing PUT using Python urllib2 - Stack Overflow

python urllib2
Rectangle 27 2

I recently read Programming Language Processors in Java and would recommend it to you as it starts with basic concepts and then takes you through the implementation of a recursive-descent compiler including code generation with plenty of discussion of alternative approaches. I've not read the other suggested books in this thread though, so can't offer a comparison with those. Don't be put off by the In Java part, if you don't know java, as the concepts and their implementation are well enough explained that you get the gist without needing a detailed understanding of Java.

I think this book is much better than the dragon book for a starter. Highly recommended.

Learning Resources on Parsers, Interpreters, and Compilers - Stack Ove...

compiler-construction interpreter parsing compiler-theory language-theory
Rectangle 27 2

I recently read Programming Language Processors in Java and would recommend it to you as it starts with basic concepts and then takes you through the implementation of a recursive-descent compiler including code generation with plenty of discussion of alternative approaches. I've not read the other suggested books in this thread though, so can't offer a comparison with those. Don't be put off by the In Java part, if you don't know java, as the concepts and their implementation are well enough explained that you get the gist without needing a detailed understanding of Java.

I think this book is much better than the dragon book for a starter. Highly recommended.

Learning Resources on Parsers, Interpreters, and Compilers - Stack Ove...

compiler-construction interpreter parsing compiler-theory language-theory
Rectangle 27 0

I've just spend a while trying to solve this issue myself and ended up with a slightly different solution to the others suggested here. I've put it in a gist with plenty of comments, but as is the SO way I'll give a brief explantion here:

Rather than modify individual instances of an old version of a class, or copy them into new instances of the new class, the idea is to set the methods of the old class (i.e. the attributes of the class itself not the instances of the class) to be the updated methods from the new class. It also takes care of chaining back over multiple versions of the class.

How to reload the code of a method of class object in Python? - Stack ...

python methods reload
Rectangle 27 0

I've just spend a while trying to solve this issue myself and ended up with a slightly different solution to the others suggested here. I've put it in a gist with plenty of comments, but as is the SO way I'll give a brief explantion here:

Rather than modify individual instances of an old version of a class, or copy them into new instances of the new class, the idea is to set the methods of the old class (i.e. the attributes of the class itself not the instances of the class) to be the updated methods from the new class. It also takes care of chaining back over multiple versions of the class.

How to reload the code of a method of class object in Python? - Stack ...

python methods reload
Rectangle 27 0

Don't know if this helps .. but I have put together a gist on what I use in my projects.

It mostly works for what I do as my routes file is generally quite concise.

The beauty of it is, that if you attempt to visit a path that doesn't exist, it won't hit any routes!

Just a side note, this is broken in the 4.0 release. At the time of writing this, you will need to put the following in your gemfile.

gem 'friendly_id', :git => 'git://github.com/norman/friendly_id.git'
gem 'friendly_id', :git => 'https://github.com/norman/friendly_id.git'

rails routes access by resource name using friendly_id gem - Stack Ove...

ruby-on-rails ruby-on-rails-3 routing slug friendly-id