Software, Physics, Data, Mountains

...and other random associations

Git-create New Github Repos

Ok, I’m too lazy to go through the web interface every time I want to add a new github repo. github api to the rescue…

The goal

I want

git create myrepo "my repo description"

to create a new github repo ‘myrepo’.

Grrr… Fix Dpms on Hawk

From here

#!/usr/bin/perl
my $cmd = q[dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'"];
open (IN, "$cmd |");
while (<IN>) {
    if (/^\s+boolean true/) {
        system '~/gpufolding/gpufah.bash';
    }
    elsif (/^\s+boolean false/) {
        system 'kill `pgrep gupfah.bash`';
        system 'kill `pgrep Folding.*home`';
    }
}

From here

#!/usr/bin/perl
#gnome
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";

open (IN, "$cmd |");

while (<IN>) {
if (m/^\s+boolean true/) {
#when screensaver activates, run the following commands
#system("/home/eric/compiled/scripts/rtorrentstart");
system("touch /home/asoukenka/rtorrenthasstarted");
} elsif (m/^\s+boolean false/) {
#when screensaver deactivates, run the following commands
#system("kill `pgrep rtorrent`");
system("touch /home/asoukenka/rtorrenthasbeenkilled");
}
}

and

#!/usr/bin/perl
#requires:
# rtorrent, screen, gnome/kde, perl
#
# Instructions:
# - Properly comment the line for gnome or kde
# - Give script execute permission (chmod +x)
# - Run script ./<scriptname> **** do not use rtorrent in script name will mess up kill command
#
# There is a log file created by the script at /tmp/autortorrent 
#
#


#gnome
#my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";

#kde
my $cmd = "dbus-monitor --session \"type='signal',interface='org.freedesktop.ScreenSaver',member='ActiveChanged'\"";
open (IN, "$cmd |");

while (<IN>) {
if (m/^\s+boolean true/) {
#when screensaver activates, run the following commands
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
system("screen -dmS rtorrent rtorrent");
system("echo \"started:\" >> /tmp/autortorrent");
system("date >> /tmp/autortorrent");
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
} elsif (m/^\s+boolean false/) {
#when screensaver deactivates, run the following commands
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
system("kill `pgrep rtorrent`");
system("echo \"stopped:\" >> /tmp/autortorrent");
system("date >> /tmp/autortorrent");
#system("ps aux |grep rtorrent >> /tmp/autortorrent");
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
}
}

from here

#!/bin/sh
gnome-screensaver-command --lock
xset dpms force off
gnome-screensaver-command --inhibit
exit

also some stuff in here

Try to run gnome-screensave in no-daemon and debug mode to see what’s going on… according to https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/193192


Some inhibit stuff from here

#!/usr/bin/python
import subprocess

#run inhibition
ss_inhibit = subprocess.Popen(["gnome-screensaver-command", "-i", "-n", 
                               "mplayer", "-r", "video"])

#run gmplayer
player = subprocess.Popen("gmplayer")

#wait for mplayer to exit
player.wait()

#kill the inhibition
ss_inhibit.kill()

or from here

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.Inhibit string:"MPlayer" string:"Watching video"

or

dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call /ScreenSaver org.gnome.ScreenSaver.SimulateUserActivity
dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.Inhibit string:"MPlayer" string:"Watching video"
gnome-screensaver-command --poke

Run Single Rspec Test

From here

./script/spec spec/models/posting_spec.rb -e"should update the analyst's employer count of active ideas"

Debug Rspec

Duh

./script/spec --debug spec/models/posting_spec.rb 

Hadoop-test-install

From Michael Noll’s hadoop on ubuntu post

mkdir /var/lib/hadoop
chown mmm.mmm /var/lib/hadoop

hadoop datanode -format

bin/start-all.sh 

hadoop dfs -copyFromLocal /tmp/gutenberg gutenberg

hadoop dfs -ls

hadoop jar /usr/local/hadoop/hadoop-mapred-examples-0.21.0.jar wordcount gutenberg gutenberg-output

hadoop dfs -ls
hadoop dfs -ls gutenberg-output

bin/hadoop dfs -cat gutenberg-output/part-r-00000
mkdir /tmp/gutenberg-output
bin/hadoop dfs -getmerge gutenberg-output /tmp/gutenberg-output
head /tmp/gutenberg-output/gutenberg-output

Multiuser Screen Sessions

ok, trying to do this for real…

I set suid on screen, so

mmm@kojiro:~/projects/ttu/doc$ ls -al /usr/bin/screen
-rwxr-sr-x 1 root utmp 340604 2010-08-17 10:55 /usr/bin/screen

becomes

mmm@kojiro:~/projects/ttu/doc$ ls -al /usr/bin/screen
-rwsr-sr-x 1 root utmp 340604 2010-08-17 10:55 /usr/bin/screen

and then /var/run/screen needs to be 755 instead of 775… i.e.,

mmm@kojiro:~/projects/ttu/doc$ ls -al /var/run | grep screen
drwxrwxr-x  5 root     utmp      100 2011-02-08 10:17 screen

becomes

mmm@kojiro:~/projects/ttu/doc$ ls -al /var/run | grep screen
drwxr-xr-x  5 root     utmp      100 2011-02-08 10:17 screen

Now, user1:

user1@kojiro:~$ screen -x -S junk -t junk

or just

user1@kojiro:~$ screen -S junk

user1 sets multiusermode

Ctrl-A :multiuser on
Ctrl-A :acladd user2
Ctrl-A :acladd user3

user2

user2@kojiro:~$ screen -x mmm/

user3

user3@kojiro:~$ screen -x mmm/

another version

For security reasons, screen by default is installed so that other users within the system can not attach to your screen sessions. To allow this to be changed one must set screen to run SUID root by doing the following (once):
sudo chmod +s /usr/bin/screen
sudo chmod 755 /var/run/screen
Then user1 can share their session on host as follows:
screen -S shared-session
Ctrla :multiuser on
Ctrla :acladd user2

user2 on host can then connect to the shared session like:
ssh user2@host
screen -x user1/shared-session

first view screen -S junk

second view screen -x -R junk


maybe this’ll work…

user1

screen -t junk

user2 becomes user1

screen -x -t junk

looks like this works… maybe overkill but wtf?

screen -xR -t junk -S junk

allegedly, screen -t junk screen -x -t junk should work

below is old

It’s possible for two users to share a screen session. This is particularly useful if multiple people want to monitor a long running task, and it’s easy to do.

user #1:

screen -R longbuild

user #2:

screen -x -R longbuild

The -x flag tells screen to allow you to attach to an already attached session. This is also good for crazy stuff like a collaborative Vim session (if you’re into that sort of thing).

Fix Spaces in Osx

defaults write com.apple.dock workspaces-wrap-arrows -boolean NO