Shortcuts:
M-: - block comment
M-/ - auto complete from context
C-M-% - regex-replace
C-q <specialChar> - C-q <TAB>, <SPACE> inserts those special chars
Commands:
M-x whitespace-mode - see all the cursing characters... :-P
M-x man RET cmd - view a man page properly in emacs
Startup file location ~/.emacs
Tip: Avoid too many non-standard configurations. Keep your configuration file small and lean. If you evolve and/or heavily modify your environment, it will be increasingly harder to stay productive when you move over machines and won't have access to your superCustomized.el
or
Hypothesis 1: make your file available through some http service. curl it down. run with emacs and watch for errors?
i.e. `emacs some option <yourConfig>.el` if $? == 1 { #don't move HEAD, latest emacs does not work }. You should let me know once you figure this out. :D
Reference links:
http://sachachua.com
Sunday, February 24, 2013
Rename bunch of files with Python
#!/usr/bin/env python
import os, re, commands
fileNameRegEx = '^([0-9])+'
pattern = re.compile( fileNameRegEx )
filesRenamed = 0
for f in os.listdir( '.' ):
match = pattern.search( f )
if match:
newFileName = "{0}.regex".format( match.group(0) )
print "Renaming {0} to {1}".format( f, newFileName )
statusTuple = commands.getstatusoutput( 'mv {0} {1}'.format( f, newFileName ) )
if (statusTuple[0] == 0): filesRenamed += 1
print "Total files renamed {0}".format ( filesRenamed )
import os, re, commands
fileNameRegEx = '^([0-9])+'
pattern = re.compile( fileNameRegEx )
filesRenamed = 0
for f in os.listdir( '.' ):
match = pattern.search( f )
if match:
newFileName = "{0}.regex".format( match.group(0) )
print "Renaming {0} to {1}".format( f, newFileName )
statusTuple = commands.getstatusoutput( 'mv {0} {1}'.format( f, newFileName ) )
if (statusTuple[0] == 0): filesRenamed += 1
print "Total files renamed {0}".format ( filesRenamed )
Thursday, February 7, 2013
Music - Above & Beyond
A post completely? (almost) unrelated to programming, software engineering. Big fan of above and beyond podcast. (http://www.mixcloud.com/aboveandbeyond). Check it out, if you like electronic, trance music and code away that python <insertYourLangHere> script, class away.
Wednesday, February 6, 2013
Managing multiple identities with git and ssh
If you have multiple git repositories, you should create an ~/.ssh/config file to reflect your "identities", here is mine:
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalPrivateKey
# Work user account
Host supercode.com
HostName supercode.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/my_workplace_companyPrivateKey
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalPrivateKey
# Work user account
Host supercode.com
HostName supercode.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/my_workplace_companyPrivateKey
Tuesday, January 29, 2013
Reset MacOSX Lion Password from terminal
Boot from Install Disc.
Open terminal.
$ resetpassword
Follow the gui and you are done.
This was really quick.
Open terminal.
$ resetpassword
Follow the gui and you are done.
This was really quick.
Sunday, January 20, 2013
groovy with emacs on ubuntu 12.04 lts
List of steps to get groovy syntax highlighting working with emacs:
so:
Optionally if you do not have your emacs configured, you will see 2 windows coming up. Make sure you enable inhibit start up screen option. That way your editor will always come up with the argument file or folder you passed.
Happy Coding!
1) Get all *.el for supporting syntax (this step assumes you have a configured github account, if false, you can manually download from github)
git clone git://github.com/russel/Emacs-Groovy-Mode.git
2) Create symbolic links to new .el groovy supporting files: (assuming you performed cmd 1 and in the same folder)
ln -s `pwd`/*.el /home/yourUserName/.emacs.d/
3) Create/append to init.el
(message "Loading emacs init.el")
;;;... <body of init.el> ...
;;; pick up modules into load path
(add-to-list 'load-path "/home/<yourUserName>/.emacs.d/")
;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start
(autoload 'groovy-mode "groovy-mode" "Major mode for editing Groovy code." t)
(add-to-list 'auto-mode-alist '("\.groovy$" . groovy-mode))
(add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode))
;;; make Groovy mode electric by default.
(add-hook 'groovy-mode-hook
'(lambda ()
(require 'groovy-electric)
(groovy-electric-mode)))
;;;... <end of body of init.el> ...
(message "Done loading emacs init.el")
(provide 'init)
3) On Ubuntu 12.04 LTS the default .emacs file is present but we need to load our newly modified /etc/<userName>/init .el
so:
rm ~/.emacs
ln -s /home/<yourUserName>/.emacs.d/init.el /home/<yourUserName>/.emacs
Optionally if you do not have your emacs configured, you will see 2 windows coming up. Make sure you enable inhibit start up screen option. That way your editor will always come up with the argument file or folder you passed.
If I missed anything, please let me know in the comments!
Happy Coding!
Wednesday, January 16, 2013
git-svn adventures
Checkout:
How to correctly checkout an existing svn repo, following a standard svn layout:git svn clone http://svnRepoAddress.com/project --stdlayout
verify that you can see branches from svn:
Checkout a branch (notice the appended "Local"):
git checkout -b featureBranchLocal remotes/featureBranch
If you are trying to create a branch, refer to this SO post.
git checkout featureBranchLocal
git svn rebase
How to revert a commit from SVN using git-svn (I recommend doing it in order from HEAD, top-down, haven't tried otherwise but it would seem you would be resolving unnecessary conflicts):
git revert <commitHash>
git revert <commitAnotherHash>
git svn dcommit
SVN should have applications of reverted commits.
Pull down new svn branches: Fetch
git svn fetch
Subscribe to:
Posts (Atom)