Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • diegor 10:48 pm on October 5, 2014 Permalink | Reply
    Tags: , , , vmware   

    HOWTO: Ctrl/Alt/Shift keys not working in VMWare 

    Sometime when using VMWare under linux, it makes impossible the usage of Ctrl/Alt/Shift keys on the virtualised OS. The solution is quite easy though. Open a terminal and type the following command:

    #> setxkbmap
    

    That’s it.

     
  • diegor 10:23 am on August 28, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: check if I am in a screen session 

    #> echo $STY

    If you are in a screen session, you’ll see something similar to

    #> echo $STY
    5413.ttys001.leonard

    If you aren’t, you’ll see nothing.

    #> echo $STY
    
    #>

     
  • diegor 5:03 pm on August 14, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: restore a deleted file in git 

    #> git rev-list -n 1 HEAD -- path_to_file  #this gives you the commit's hash
    #> git checkout commit_hash^ -- path_to_file # it restores the file

     
  • diegor 10:26 am on July 18, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: rename screen session 

    Within screen:

    C-a :sessionname newSessionName

    where C-a is Ctrl-a

    Without attaching a screen session:

    #> screen -X sessionname newSessionName

    If you have multiple screen running you have to specify which one to rename:

    #> screen -S sessionToRename -X sessionname newSessionName

     
  • diegor 6:44 pm on June 19, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: schedule repeating events with Python 

    import sched
    import datetime, time
    
    class PeriodicScheduler(object):                                                
        def __init__(self):                                                         
            self.scheduler = sched.scheduler(time.time, time.sleep)                 
                                                                                    
        def setup(self, interval, action, actionargs=()):                           
            action(*actionargs)                                                     
            self.scheduler.enter(interval, 1, self.setup,                           
                            (interval, action, actionargs))                         
                                                                                    
        def run(self):                                                              
            self.scheduler.run()
    
    #This is the event to execute every time
    def periodic_event():
        print datetime.datetime.now()
    
    INTERVAL = 1 # every second
    periodic_scheduler = PeriodicScheduler() 
    periodic_scheduler.setup(INTERVAL, periodic_event) # it executes the event just once
    periodic_scheduler.run() # it starts the scheduler
    

     
  • diegor 6:40 pm on April 2, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: move a commit to another branch using GIT 

    #> git log #Get the commit_ID that you want to move
    #> git checkout [right_branch]
    #> git cherry-pick [commit_ID]

     
  • diegor 6:10 pm on March 13, 2014 Permalink | Reply
    Tags: awk, ,   

    HOWTO: print the nth line of a file 

    #> awk 'NR==1524' file.txt # print the 1524th line of the file using awk
    #> sed -n '1244p' file.txt # print the 1244th line of the file using sed
    

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel