vim
make vim format json
1 |
:%!python -m json.tool |
note when pulling data from a mongo database, it uses
ISODATE()
and a few other custom mongo things. You have to remove those to get the command to work. Otherwise it just tells you that there is no json for it to format.
make vim format xml
1 |
:%!xmllint --format - |
search for files containing text, and open up the list of files that contained that text in vim
1 |
grep --include=*.filetype -l -r <search term> <root directory to begin recursive search> | mvim - |
Once you have the list of files containing the search term open, you can put the cursor over the file and press
<ctrl-w>f
to open the file the cursor is over in a split
Replace Text
replacing text in tons of files with sed in os x
1 |
grep --include=*.{ext1,ext2} -rl searchTerm dir |
this will list all files that contain some text. It can be piped into sed like this
1 |
<grep command> | xargs sed -i.bu 's/find/replace/g' |
and that will create a backup of every modified file. the backup will have bu as the extension. change that with the
-i.bu
part of the command
you can also make it so there is no backup file created like this (make sure you’re in a source control system for safety)
1 |
| xargs sed -i '' 's/search/replace/g' |
Here’s what i use when updating nuget packages in multiple csproj’s (only safe with certain repos that don’t have install scripts)
1 |
grep --include=*.{config,csproj} -rl 1.4.0-alpha . | xargs sed -i '' 's/1.4.0-alpha0098/1.4.0-alpha0109/g' |
sometimes it can also be useful to use ruby for substitutions instead of sed. do something like this
1 |
grep --include=*.{config,csproj} -rl 1.4.0-alpha . | xargs ruby -pi.bak -e "gsub('find', 'replace')" |
XCode
When debugging auto layout ambiguity, pause the application and run the auto layout trace in the debugger console.
1 |
po [[UIWindow keyWindow] _autolayoutTrace] |
Xamarin does not have very good debugging tools. In particular, it doesn’t have a great way to determine the currently visible ViewController. This is what I use to do that
1 |
UIKit.UIApplication.SharedApplication.KeyWindow.RootViewController.Class |
The Namespace
UIKit
shouldn’t be required, but sometimes leaving it off doesn’t work. No clue why.
GitBash
Start git bash in a specific file by changing properties -> Start in
Compress and Split large files
1 |
7z a file.7z input -v500m |
zip
1 2 3 4 |
zip -r -s <max size in mb> ArchiveName.zip FolderToArchive/ #size can be a different unit such as gb zip -r -s 1g ArchiveName.zip FolderToArchive/ |