Vim yanking range of lines

Yank lines 81-91 :81,91y<enter> If your fingers don’t like to find the : and , keys, this would work as well (go to line 81, yank 11 lines) 81gg11yy My only use of g is 5gg. To go to the 5th line. 22gg: 22nd line. As jimbo said, it’s really only a modifier for some … Read more

Sample http range request session

The following exchange is between Chrome and a static web server, retrieving an MP4 video. Initial request – for the video. Note the Accept-Ranges response header to indicate the server has range header support: GET /BigBuckBunny_320x180.mp4 Cache-Control: max-age=0 Connection: keep-alive Accept-Language: en-GB,en-US,en Host: localhost:8080 Range: Accept: text/html,application/xhtml+xml,application/xml,*/* User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 … Accept-Encoding: … Read more

range over character in python

This is a great use for a custom generator: Python 2: def char_range(c1, c2): “””Generates the characters from `c1` to `c2`, inclusive.””” for c in xrange(ord(c1), ord(c2)+1): yield chr(c) then: for c in char_range(‘a’, ‘z’): print c Python 3: def char_range(c1, c2): “””Generates the characters from `c1` to `c2`, inclusive.””” for c in range(ord(c1), ord(c2)+1): … Read more

Pandas: create new column in df with random integers from range

One solution is to use numpy.random.randint: import numpy as np df1[‘randNumCol’] = np.random.randint(1, 6, df1.shape[0]) Or if the numbers are non-consecutive (albeit slower), you can use this: df1[‘randNumCol’] = np.random.choice([1, 9, 20], df1.shape[0]) In order to make the results reproducible you can set the seed with numpy.random.seed (e.g. np.random.seed(42))