Advertisement
Guest User

Untitled

a guest
Aug 4th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. #Common Commands
  2.  
  3. ### System Utility
  4. * Upgrade all packages with pip
  5. ```shell
  6. sudo pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo pip install -U
  7. ```
  8. * Split and Concat files in Shell
  9. ```shell
  10. split -l 10000 new_data_lower.txt
  11. cat *.txt > merged-file
  12. ```
  13. * Change Mode to Executable
  14. ```bash
  15. sudo chmod +x countdown.sh
  16. sudo chmod +x new_thisweek.sh
  17. ```
  18. * Kill a process by PID
  19. ```bash
  20. kill -9 pid
  21. ```
  22. * Print out first/last few lines
  23. ```bash
  24. head -n 1 file # change 1 to any number
  25. tail -n 1 file
  26. # if only print out first line
  27. sed -n 1p file
  28. head -n 1 file
  29. awk 'NR==1' file
  30. ```
  31. * Count total number of lines in a file
  32. ```bash
  33. sed -n '$=' filename
  34. wc -l filename
  35. ```
  36. * Apply a change in a file (e.g., .bash_profile)
  37. ```bash
  38. source .bash_profile
  39. ```
  40. * VPN PrivateInternetAccess Usernam
  41. ```
  42. p6441849
  43. ```
  44. * remove a directory
  45. ```
  46. rm -r directory
  47. ```
  48. * Change default shell
  49. ```
  50. chsh -s $(which zsh)
  51. chsh -s $(which bash)
  52. ```
  53.  
  54. ### Stata
  55. * Plotting coefficient estimates
  56. ```stata
  57. parmby "xtreg ..., fe r", norestore
  58. eclplot estimate min95 max95 parmseq
  59. ```
  60. ```stata
  61. //identify nonnumeric strings and drop
  62. gen byte notnumeric = real(twitter_count)==.
  63. /*makes indicator for obs w/o numeric values*/
  64. tab notnumeric
  65. /*==1 where nonnumeric characters*/
  66. list twitter_count if notnumeric==1
  67. /*will show which have nonnumeric*/
  68. drop if notnumeric==1
  69. ```
  70.  
  71.  
  72. ### Python
  73. * To get a value of a key in a dictionary
  74. ```python
  75. dictionary.get('key', 'return_otherwise')
  76. ```
  77. * String formatting
  78. ```python
  79. a = 'John'
  80. b = 'Doe'
  81. 'Hi there %s %s. How is it going' % (a,b) #c-like placeholder
  82. 'Hi there {0} {1}. How is it going'.format(a,b) #python method
  83. ```
  84.  
  85. ### System
  86. * Get rid of the field codes with Endnote
  87. ```cmd
  88. CMD + Shift + F9 + fn
  89. ```
  90.  
  91. ### Git
  92. ```bash
  93. cd /Users/Hong/Google Drive/website
  94. git add.
  95. git commit -m "message"
  96. git push origin master
  97. ```
  98.  
  99. ### Update personal website
  100. ```bash
  101. cd "/Users/Hong/Google Drive/website"
  102. scp * ykhong1@general.asu.edu:www # push all files to the www folder under the asu public address
  103. scp -r files/ ykhong1@general.asu.edu:www # push the files folder to the files folder under www folder in asu address
  104. scp files/social.png ykhong1@general.asu.edu:www/files
  105. ssh ykhong1@general.asu.edu
  106. ```
  107.  
  108. ### Update the Hack Font
  109. ```
  110. brew cask install caskroom/fonts/font-hack
  111. ```
  112.  
  113. ### Access AWS Server
  114. ```bash
  115. sudo ssh -i hongkey1.pem ubuntu@52.32.158.42
  116.  
  117. scp -i hongkey1.pem /Users/Hong/Google\ Drive/Research/Freelancer\ Crawler/Final\ Data\ and\ Scripts/Latest/Database/FreelancerDump20160716.sql ubuntu@52.43.46.23:~/data/
  118.  
  119. ## upload a directory
  120. sudo scp -r -i hongkey1.pem /Users/Hong/Google\ Drive/Research/Freelancer\ Crawler/Final\ Data\ and\ Scripts/Latest/Scripts/ ubuntu@52.43.46.23:~/scripts/
  121.  
  122. ##install mysqldb (mysql-python) on linux
  123. sudo apt-get install libmysqlclient-dev python-dev
  124. sudo ~/anaconda2/bin/pip install mysql-python
  125. ```
  126. ### MySQL
  127. ```mysql
  128. #import:
  129. mysql > set global max_allowed_packet=100000000
  130.  
  131. in command line: mysql -u root -p --max_allowed_packet=100m freelancer<e:dump.sql;
  132.  
  133. #dump:
  134.  
  135. mysqldump --user=root --password=****** --database gaf > d:dump.sql
  136.  
  137. #Grant only select function
  138. GRANT SELECT ON *.* TO 'chen'@'%' IDENTIFIED BY 'isr';
  139. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement