跳到主要內容

發表文章

目前顯示的是 8月, 2015的文章

Git - Formatting Log Output

Graphs The  --graph  option draws an ASCII graph representing the branch structure of the commit history. This is commonly used in conjunction with the  --oneline  and  --decorate  commands to make it easier to see which commit belongs to which branch: git log --graph --oneline --decorate For a simple repository with just 2 branches, this will produce the following: * 0e25143 (HEAD, master) Merge branch 'feature' |\ | * 16b36c6 Fix a bug in the new feature | * 23ad9ad Start a new feature * | ad8621a Fix a critical security issue |/ * 400e4b7 Fix typos in the documentation * 160e224 Add the initial code base The asterisk shows which branch the commit was on, so the above graph tells us that the  23ad9ad  and  16b36c6  commits are on a topic branch and the rest are on the  master  branch. While this is a nice option for simple repositories, you’re probably better off with a more full-featured visualization tool ...

picamera - Recording video to a stream

import io import picamera stream = io.BytesIO() with picamera.PiCamera() as camera:     camera.resolution = (320, 240)     camera.start_recording(stream, format='h264', quality=30)     camera.wait_recording(10)     camera.stop_recording()

pi camera - take a picture (using python)

import time import picamera with picamera.PiCamera() as camera:     camera.resolution = (320, 240)     camera.start_preview()     time.sleep(2)     camera.capture('foo.jpg')

Accessing the Webcam with Python - Ubuntu

To install SimpleCV for python you'll need to start by installing the other libraries it depends on. Use apt-get:  ~ $ sudo apt-get install python-opencv python-scipy python-numpy python-pip Next, ~ $ sudo pip install https://github.com/ingenuitas/SimpleCV/zipball/master Next, ~ $ vim simplewebcam.py put the following code in it and save. from SimpleCV import Camera, Display from time import sleep myCamera = Camera(prop_set={'width':640,'height':480}) myDisplay = Display(resolution=(640,480)) while not myDisplay.isDone():    myCamera.getImage().save(myDisplay)    sleep(.1) ~ $ python simplewebcam.py then you can see the screen pop-out  

How to query mongodb with “like”?

db.users.insert({name: 'paulo'}) db.users.insert({name: 'patric'}) db.users.insert({name: 'pedro'}) db.users.find({name: /a/})  //like '%a%' out: paulo, patric db.users.find({name: /^pa/}) //like 'pa%' out: paulo, patric db.users.find({name: /ro$/}) //like '%ro' out: pedro Multiline Match for Lines Starting with Specified Pattern The following example uses the  m  option to match lines starting with the letter  S  for multiline strings: db . products . find ( { description : { $regex : /^S/ , $options : 'm' } } ) The query matches the following documents: { "_id" : 100 , "sku" : "abc123" , "description" : "Single line description." } { "_id" : 101 , "sku" : "abc789" , "description" : "First line\nSecond line" } Without the  m  option, the query would match just the follo...