Don't wanna be here? Send us removal request.
Text
20 most useful things to do with the unix shell (part 1)
1. wtf is taking up all my disk space?
This is useful for people with mac ssd drives that fill up so fast:
$ du -sk * | sort -rn
(du is for disk usage, sort -r is sort things in reverse order, this guy --> | "pipe" says that the output of du and make it be the input of sort.
this will print out what is taking up the most room in the current directory with biggest files, directories first
2) wtf is taking up my diskspace, part 2
$ df ---> this shows you all the different devices (like a cd, an external drive, local filesystems) and how much room they are using
3) Wtf is running on my system?
$ ps aux ---> this gives you all the running processes (sort of like a program under unix, but running), who is running them, what % of your cpu and memory they are taking up. Also good for "why is firefox using up all my memory?"
4) wtf is generally going on with this system?
You can look at system logs, usually found in /var/log. Good logs are syslog and application specific logs. you can look at them with programs like
$ less syslog
or
$ tail -f syslog --> this keep the file open at the end and when new things come in it displays them on the screen
honestly syslog is not the most helpful to newcomers it's mostly a bunch of kernel stuff and it's good for finding out if your kernel recognizes certain hardware or is freaking out bc system is overheating
5) What are the files that contains "hsjuju is awesome" again?
$ grep -r "hsjuju is awesome" *
this looks recursively through all the files starting at the current directory for the string "hsjuju is awesome" and lists all of them
6 notes
·
View notes
Link
As a programmer, one of the first things that you need for serious program development is a debugger. Python has a debugger, which is available as a module called pdb (for "Python DeBugger", natura...
Really good post on pdb
0 notes
Text
google chrome dev tools
Wow, google chrome dev tools are amazing! They make debugging JS soooo much easier. Just to give one example, you can set breakpoints on events! How cool is that? I've been using FF forever, and I'm really impressed with these dev tools. Seriously, check them out!
0 notes
Text
keyboard shortcuts for OSX
To save text, just higlight it and drag to the desktop.
To switch between windows in the same application, cmd-~
from this article
0 notes
Text
pgrep
do this instead of ps aux | grep cron: pgrep cron! Sweet!
0 notes
Text
Today's hack
Filtering bug tracking system into its own folder so it doesn't clutter up my inbox!
0 notes
Link
Great practice coding interview questions. Technical interview preparation for software engineers. Make tech interviews a piece of cake!
0 notes
Text
Hack of the day: jump to end and beginning of line in your shell
With Bash:
control-a: jump to beginning of line
control-e: jump to end of line
0 notes
Text
productivity hacks for programmers
I've decided to devote 15 mins at the start of every work day to investigate a new productivity hack, whether it's learning a new keyboard shortcut for Sublime, writing myself a shell alias for a command I use all the time, or installing a package to make my life easier. I thought I post a link a day or something.
Today:
https://github.com/kemayo/sublime-text-2-goto-documentation
Go to Python doc straight from sublime with super-shift-h
0 notes
Text
How to post to twitter from the command line
Here's how to write a tiny program that posts to twitter from the command-line.
1) Make sure you have virtualenv and virtualenv wrapper. This is so you can install modules specific to this project without messing up your python environment. Newcoder.io has a good page on installating virtualenv.
$ cd project/couch-tweeting
2. Create a virtualenv:
mkvirtualenv couch-tweeting
You'll see (couch-tweeting) in front of your command-prompt
3. Install the python-twitter and its dependencies from http://code.google.com/p/python-twitter/
Untar in your couch-tweeting directory.
Run the setup commands
$ python setup.py build
$ python setup.py install
Install the dependencies.
pip -r requirements.txt
4. Make sure it's imported, start the python command-line interpreter and import the module.
$ python
>> import twitter
>> exit()
If you get no errors then it imported properly.
5. Now you need to set up some auth stuff. This is so your "app" (really, any 3rd party program that wants to connect to twitter) can connect to twitter and ask it for information.
Go to the twitter dev site and get this stuff at https://dev.twitter.com
You'll need to log in with your existing twitter account. Then under 'My applications', click 'Create a new application', and enter the info.
You need to make sure your app has read-write access so it can write to your timeline. The default is for apps to be read-only.
Go to 'Settings', then 'Application Type' and click "Read-Write" and then click save/update.
To be able to log in to twitter, you need OAuth credentials, basically saying you're authorized to do things on twitter. You can find those under Details >> OAuth settings. You'll need these as parameters to python-twitter.
6. You can test it out from the CLI:
$ python
>> import twitter
>> api = twitter.Api(consumer_key='your key', consumer_secret='your_secret', access_token_key='yourtoken', access_token_secret='yoursecret')
All this info you can get from the Details >> OAuth settings in the page for your twitter app. Note that if you change something important, like if your app is read-only, or read-write, you have to regenerate the access token.
Then you can try posting something!
>> message = api.PostUpdate("Hello world")
Go check on your twitter timeline, the message should have posted!
7. At this point you're all set to write a program or you can play with twitter from the command-line some more.
8. So now if we want to be able to do
$ 'couch-tweeter "my message woo"
as a program by itself instead of having to fire up the python interpreter, we have to write an actual program. We could just put the above few lines in a file, but it would be annoying to have to edit the file each time we want to write a new message. So we want to pass the message/tweet as a command-line argument. Python has an amazing parseArgs module that handles parsing arguments, errors, help messages, all for us.
Then our main function just looks like this:
def main():
# here we get the arguments opts = parse_args()
# parsargs puts its results in opts (I'll show you how to tell it to put the message in opts.status in one second) message = api.PostUpdate(opts.status) print message if __name__ == '__main__': main()
10. The parseargs function looks like this:
def parse_args():
# this says "this is what this program does" parser = argparse.ArgumentParser(description="Post something to twitter!")
# this says "watch out for this argument, it's the first one, let's call it 'status' parser.add_argument('status', metavar='status', help='What do you want to say?') # get the args and put them into opts opts = parser.parse_args()
# it knows that opts should have a status, if not, it's an error! if not (opts.status): parser.error("You have to specify a message to post!") return opts
(I took this and modified it from newcoder.io.) This could probably be explained better, let me know if you have any questions.
Make sure to include the parseargs module at the top of your program
import twitter import argparse
See the complete tiny program here:
https://github.com/almosteverywhere/couch-tweeting
2 notes
·
View notes
Text
__ALL THOSE WEIRD PYTHON FUNCTIONS__
here's the lowdown on all those weird python functions: __foo__ (called "Dunder" functions ) http://www.rafekettler.com/magicmethods.html
0 notes
Text
how twitter works, scalability
http://www.infoq.com/presentations/Twitter-Timeline-Scalability
0 notes
Text
notes from Peter Norvig talk last night:
You can add memoization to any function in python as a decorator to do dynamic programming
"All models are wrong but some models are useful"
"We're about halfway to the end of the numbers"
Given a corpus of text, you can determine reading level
Python lets you add attributes to functions
Main google hiring problem is getting engineers to think on that scale, not 1 computer but millions
His favorite problem is the problem of how your determine meaning.
0 notes