Walid-Shouman
10/30/2016 - 2:51 PM

things to do upon having a new windows installation

things to do upon having a new windows installation

Install Python

  1. Get the latest x86 (not 86-64 even for 64bit machines) Python downloads page
  2. Open commandline and update pip using python -m pip install -U pip setuptools
  3. In a new directory create ur venv using python -m venv ., activate it using .\Scripts\activate.bat and start development

TODO: manage gitignores and folder structure.
NOTE: pip and venv installation are detailed in Python's wiki: Installing Packages.
NOTE: venv doesn't work with python2.7, we'll need to fallback to virtualenv, use pip2 install virtualenv for that, then initialize the evn with python2 -m virtualenv . and activate with .\Scripts\activate, and of course we will need to register pip2 and python2 ... check alias setup below for that.
NOTE: deactivate using .\Scripts\deactivate

Installing Code generator

  • To install cogapp package for code generation, we get the cogapp package link and install it like this pip install https://pypi.python.org/packages/source/c/cogapp/cogapp-2.5.tar.gz.
  • To use cogapp as a python module python -m cogapp .\PATH\TO\FILE.py, for more about the arguments and usage

Installing pdfMiner

  • create a new python2 project with it's virtualenv
  • install pdfminer pip install pdfminer
  • download the pdf-to-markdown project https://github.com/johnlinp/pdf-to-markdown
  • extract the folder into the project (ie: app/convertor)
  • use python app/convertor/main.py C:\FULL\PATH\TO\PDF\FILE.pdf
  • output should be displayed at where we're at
  • NOTE: the pdfminer currently has a bug that halts conversion, unforutnately It got me stung!

Setup Windows Aliases

Reference Stackoverflow question.

Alias creation

In My Documents create the file cmd_aliases.cmd with the following content.

@echo off

DOSKEY ls=dir $*
:: TODO: replace C:\Python27 with the default installation directory for python2
DOSKEY python2=C:\Python27\python.exe $*
DOSKEY pip2=C:\Python27\Scripts\pip2.exe $*

For more examples check the reference

Presistence

Setup the following reg: in regedit.exe, navigate to HKEY_CURRENT_USER -> Software -> Microsoft -> Command Processor, then add a string reg, named AutoRun and valued %USERPROFILE%\Documents\cmd_aliases.cmd

Create custom batches

Start apps

If one would always open cmd to run a project, and may continue working from cmd, it may be a hassle to do that manually each time.
In a new my_super_init.bat file, add start cmd.exe /k "more-batch-commands-here" that will open the cmd and give you control after commands finish, OR add start cmd.exe /c "more-batch-commands-here" that will terminate the cmd after the cmd is done.
Reference SO question

Set ENV

SO answer

Install Git

Install editors

@echo off
:: this is a file template for cmd_aliases mentioned in the main tutorial
:: originally captured from the reference SO question http://stackoverflow.com/questions/20530996/aliases-in-windows-command-prompt

:: Temporary system path at cmd startup (examples)

::set PATH=%PATH%;"C:\Program Files\Sublime Text 2\"

:: Add to path by command (examples)

::DOSKEY add_python26=set PATH=%PATH%;"C:\Python26\"
::DOSKEY add_python33=set PATH=%PATH%;"C:\Python33\"

:: Commands
DOSKEY ls=dir $*
:: TODO: replace C:\Python27 with the default installation directory for python2
DOSKEY python2=C:\Python27\python.exe $*
DOSKEY pip2=C:\Python27\Scripts\pip2.exe $*

:: (examples)
::DOSKEY ls=dir /B
::DOSKEY sublime=sublime_text $*  
    ::sublime_text.exe is name of the executable. By adding a temporary entry to system path, we don't have to write the whole directory anymore.
::DOSKEY gsp="C:\Program Files (x86)\Sketchpad5\GSP505en.exe"
::DOSKEY alias=notepad %USERPROFILE%\Dropbox\alias.cmd

:: Common directories (examples)

::DOSKEY dropbox=cd "%USERPROFILE%\Dropbox\$*"
::DOSKEY research=cd %USERPROFILE%\Dropbox\Research\