Google AdSense

Wednesday, January 23, 2013

comparison of cgminer, poclbm, mac, and linux

At first this was about getting cgminer working on mac, with minimal effort...It turns out more than minimal effort is required. Anyway It's probably a nice read if your interested in bitcoin mining.

I was using a macbook pro from Mid 2010(4 gigs of ram, intel core 2 duo) An old linux box I built with 2 cores(amd) And the graphics card is a 6970 or 6950 I can't remember, it's the one with the shaders off, that you can unlock with a firmware update. And a BFL Single FPGA

Wire shelf, panels off I basically took my fedora core script and made some changes. I like cgminer, probably because the bitforce documentation said it was going to be the harder one to get working(Fuck the world, choose the wrench). And my single(FPGA) was acting funny and making noises. Essential the fan was to close or something, how that happend over the past 6 months I don't know, but I took it all apart, and then I reassembled the peices I thought it needed to work. I rescured the fan tight, but not so tight it was bumping as before, and I ran the fan wire in such a way it wouldn't fall into the fan. and then I elevated the feet with two notebooks, and it started running better than ever, hopefully by the end of writing this, it will be sitting on a wire shelf providing it with the same extra ventelation the two notebooks propping it up, now are. Now it normally runs on my linux box, but I decided I wanted to see if it ran on my Mac, so what I did was run the script below to install cgminer. If you notice I enable bitforce compatibility in the script.

So on my *nix box I was topping out at about 877
And on my mac box I'm topping out at...
However with my linux box, what i was able to do was to start using cgminer to do my graphics card which was topping out at 350 usually running at about 330 -340, and that's with --od-enable Clocks set at 920,1250, I saw the occasional problem if I bumped it to 925, 1250.

You have to have brew installed to do this
Make this script below then run it.

#!/usr/bin/perl
use strict;
use warnings;

my $brew;

my @brew_installs = qw( 
    autoconf    automake    binutils    boost   bzip2   curl    curl    curl-ca-bundle      curl-ca-bundle      cyrus-sasl2     db48    flex    gdbm    gdbm    gettext            glib2    gnutls      gperf   help2man    icu     jansson     jpeg    kerberos5   libffi      libgcrypt   libgpg-error    libiconv    libidn      libpng      libtasn1    lzo2      m4    miniupnpc   ncurses     openssl     ossp-uuid   p5-locale-gettext   p5.12-locale-gettext    perl5   perl5.12    perl5.12    pkgconfig   pv      qemu    qrencode             readline   texinfo     xz      yasm    zlib )
;

&array_cracker();

           sub array_cracker(){
            foreach(@brew_installs){
               print $_; 
                  $brew = `brew install $_`;
                     print $brew;
                       }   
                       }   


Now I tried hard to script the next part but I had some problems so here are some manual commands you will have to type in:

cd ~
mkdir Build
cd Build
git clone https://github.com/ckolivas/cgminer.git
cd cgminer
./autogen.sh
./configure --enable-scrypt
sudo make install

I didn't have any problems after that, some people said before they did their commands they had to do this: eval `brew --config | grep HOMEBREW_PREFIX | sed 's/: /=/'` sudo bash -c 'echo '$HOMEBREW_PREFIX/share/aclocal' >> `aclocal --print-ac-dir`/dirlist' I imagine you would want to do that after all your installs from the perl brew script. So what's the verdict on speed. By using cgminer on my *nix box rather than poclbm i picked up about 10Mhs, it seems to consistently run at 362. Now the bitforce fpga, seemed to run about 800 on average, sitting in the same place with the side cover off, and as high as 1000(on the mac). However, moving it to it's new location, it seems to be running consistently in the high 800s. What does this mean....Well I can't leave it hooked up to my mac all the time as it is a laptop I use for work and have to go places with it as such. However, it's new location on a wire shelf(ie a shelf less likely to get hot), it's side panels taken off, those are permenant. And when i finally reconnect it to the linux box, I will be using cgminter to run both my fpga and gpu. And next weekends experiment will be trying the bitforce with raspberry pi, and also switching them away from deepbit.net, and back to my favorite pool fireducks horrible horrendous terrible tremendous pool. PS My mac command looked like this: cgminer --scan-serial /dev/cu.usbserial-00001024 --url deeptbit.net:8332 --user dusty@safenachos_fam --pass hammer --verbose Reason being the /dev/tty.usbetc Didn't work, and I'm sure there is a duhuh explanation for why that is, but just in case you didn't know.

Sunday, January 20, 2013

Mac laptop bitcoin setup

Screen Shot 2013-01-20 at 8.57.55 PM (2)

This isn't so much mining with a mac as it is, using one to make sure your miners are doing what they're supposed to be doing. I use a linux machine for mining, not that it matters.
I used geektool heavily for this one. http://projects.tynsoe.org/en/geektool/

If you'll look you'll see on my left screen(I think the right one is up on flickr, if you want to follow the link), you can see one large number, which is the current difficulty of bitcoin. To get all the text on this screen I used geektool, I believe I set that particular command with a 10 minute refresh(which is really unnessecary because difficulty should only change about once every two weeks, I think but with asics coming I wanted to keep my eye on it).

That command is from geek using the shell option, and the command is: curl -L http://blockexplorer.com/q/getdifficulty
The one under that is just the date command, and I have it set for 1 second refresh so it's accurate within a second, I was somewhat scared to do this I thought the constant refreshing might put stress on my system but that's not true.
Now the number under that is my current mining speed, judged by the number of shares in the last 5 minutes,and I wrote a script to do that:

<php

url = "http://hhtt.1209k.com/user-details-json.php?user=13nQ57at15LYJWZ5m62Ra2cEtTJkMkvAR9";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

$output = curl_exec($ch);
curl_close($ch);

$fireduck = json_decode($output);

print_r($fireduck->hashrate->last_5_min);

?>

Originally I had a loop to keep checking the json, but I found that using the refresh setting in geek tool, worked just as well.

Saturday, January 19, 2013

Avocado.io, iCal update

I've actually been using this one, so here is an update. The codes a little cleaner, and only one error is thrown, lol. Link to the old one


<?php

define("_AVOCADO_API_URL_BASE", "https://avocado.io/api/");
define("_AVOCADO_API_URL_LOGIN", _AVOCADO_API_URL_BASE . "authentication/login");
define("_AVOCADO_API_URL_COUPLE", _AVOCADO_API_URL_BASE . "couple");
define("_AVOCADO_COOKIE_NAME", "user_email");
define("_AVOCADO_USER_AGENT", "Avocado Test Api Client v.1.0");

$date = $argv[1];
$military = $argv[2] * 60;
$military_two = $military * 60;
$name = $argv[3];
if (preg_match('/^\d{1,2}\/\d{1,2}\/\d{4}$/', $date)) { 
 $seconds = strtotime($date);
 $minutes_to_add = (($seconds - time()) / 60) + $military;

 $avocadotime =($seconds+ $military_two) * 1000;


 $milliseconds = $avocadotime;
 $two_more_milli = $avocadotime + 12000;
 $two_more = $minutes_to_add + 2;

 $appscript = ">>END
set now to (current date)
 set eStart to now + $minutes_to_add * minutes
 set eEnd to now + $two_more * minutes
 set eName to \" $name \"
 set alarmTime to 0 -- alarm at the exact moment of the event

 tell application \"iCal\"
  set newEvent to make new event at end of events of calendar \"Home\" with properties {summary:eName, start date:eStart, end date:eEnd}
   make new display alarm at end of display alarms of newEvent with properties {trigger interval:alarmTime}
   end tell
END";
}
`osascript $appscript`;


$api = new AvocadoAPI();
$api->updateFromCommandLineInput();
$api->createReminder($milliseconds, $two_more_milli, $name);
class AvocadoAPI {
  var $couple,
      $authManager;

  function AvocadoAPI() {
    $this->authManager = new AvocadoAuthManager();
  }

  function updateFromCommandLineInput() {
    $this->authManager->updateAuthFromCommandLineInput();
    $this->updateCouple();

    # Check that the response from the Avocado API was valid.
    if ($this->couple == null) {
      print "FAILED.  Signature was tested and failed. Try again and check the auth information.\n";
    } else {
      print "SUCCESS.\n\nBelow is your Avocado API signature:\n" .
        $this->authManager->signature . "\n";
    }
  }
  function getCouple(){
//  $qry_str = "?avosig=".$this->authManager->signature;
  $ch = curl_init();

  // Set query data here with the URL
  curl_setopt($ch, CURLOPT_URL, _AVOCADO_API_URL_BASE."calendar");
//  $this->signCurlRequest($ch);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, '3');
  $content = trim(curl_exec($ch));
  curl_close($ch);
  $content = json_decode($content);
  print_r($content);
  }
  function createReminder($milliseconds, $two_more_milli, $name){
//  $qry_str = "?avosig=".$this->authManager->signature;
   $ch = curl_init(_AVOCADO_API_URL_BASE."calendar");
  $fields = array (
  "start" => urlencode($milliseconds),
  "end" => urlencode($two_more_milli),
  "title" => $name,
  "location" => '',
  "description" => $name,
  "timezone" => "America/Chicago"
  );
    curl_setopt($ch, CURLOPT_POSTFIELDS,  $fields);
 curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, _AVOCADO_USER_AGENT);
 $this->signCurlRequest($ch);

  $returndata = curl_exec ($ch);
    $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 curl_close($ch);

//  $content = json_decode($content);
//  print_r($content);
 echo $returndata;
    $this->createdReminder = $response_code == 200 ? json_decode($returndata) : null;
 echo $this->createdReminder;
  }

  
  function updateCouple() {
    # Send the POST request.
    $ch = curl_init(_AVOCADO_API_URL_COUPLE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  //  $this->signCurlRequest($ch);
    $output = curl_exec($ch);
    $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    # Use the HTTP response code to test if a valid API request was made.
    $this->couple = $response_code == 200 ? json_decode($output) : null;
  }

  function signCurlRequest($ch) {
    curl_setopt($ch, CURLOPT_COOKIE, _AVOCADO_COOKIE_NAME . "=" . $this->authManager->cookie);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-AvoSig: " . $this->authManager->signature));
    curl_setopt($ch, CURLOPT_USERAGENT, _AVOCADO_USER_AGENT);
  }
}


class AvocadoAuthManager {
  var $cookie,
      $developer_id,
      $developer_key,
      $email,
      $password,
      $signature;

  function AvocadoAuthManager() {}

  function updateAuthFromCommandLineInput() {
    # Ask the user for all of the necessary authentication info
    $this->email = 'dustycarver@gmail.com';
    $this->password = 'pandabear';
    $this->developer_id = 43;
    $this->developer_key = '2EWP5Rp8vbBxYRFhwZLldd3JPXrZ1HurTM3GUV3yqpPsqmuEnL8lIpI1MxbyzXqT';
    $this->updateSignature();
  }

  function updateSignature() {
    # Get a new cookie by logging into Avocado.
    $this->updateLoginCookie();

    # Hash the user token.
    $hashed_user_token = hash("sha256", $this->cookie . $this->developer_key);

    # Store the new signature.
    $this->signature = $this->developer_id . ":" . $hashed_user_token;
  }

  function updateLoginCookie() {
    $fields = array(
      'email'=>urlencode($this->email),
      'password'=>urlencode($this->password)
    );

    # Send the POST request.
    $ch = curl_init(_AVOCADO_API_URL_LOGIN);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS,  get_querystring_from_array($fields));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, _AVOCADO_USER_AGENT);
    $header = substr(curl_exec($ch), 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
    curl_close($ch);

    # Store the cookie for use in later API requests.
    $this->cookie = get_cookie_from_header($header, _AVOCADO_COOKIE_NAME);
  }
}


#-----------------------------------------------------
# Mama's little helpers: functions we needed for this.
#-----------------------------------------------------

function get_querystring_from_array($fields) {
  $fields_string = null;
  foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
  rtrim($fields_string, '&');
  return $fields_string;
}

function get_cookie_from_header($header, $cookie_name) {
  preg_match('/^Set-Cookie: ' . $cookie_name . '=(.*?);/m', $header, $cookie_array);
  return $cookie_array[1];
}

function get_input_silently($msg){
  # NOTE: stty only works on *nix systems.
  system('stty -echo');
  $input = get_input("Password");
  system('stty echo');
  print "\n";
  return $input;
}

function get_input($msg){
  fwrite(STDOUT, "$msg: ");
  return trim(fgets(STDIN));
}

?>

Thursday, January 17, 2013

Push to iCal, and avocado.io

This is a terrible one you guys. I feel I need to apologize in advance. This script is poorly put together, has errors, and is generally not of a good quality.It's an amalgam of haberdash. Suprisingly enough though… it works. I wanted to be able to, create an alarm event in iCal, that also pushed to avocado. Avocado.io is a shared list for "you and your favorite person", I had a similiar idea and it's why I purchased the domain shoprlistr.com, however I clearly didn't pull the trigger fast enough on that one…or at all for that matter. I knew that pushing to ical would be easy with applescript, so what I did was devoted some time to creating a script that did just that. THERE IS A CODE UPDATE TO THIS POST

<<END
set now to (current date)
 set eStart to now + $minutes_to_add * minutes
 set eEnd to now + $two_more * minutes
 set eName to \" $name \"
 set alarmTime to 0 -- alarm at the exact moment of the event

 tell application \"iCal\"
  set newEvent to make new event at end of events of calendar \"Home\" with properties {summary:eName, start date:eStart, end date:eEnd}
   make new display alarm at end of display alarms of newEvent with properties {trigger interval:alarmTime}
   end tell
END
I interspersed some php, essentially to take arguments at the command line. And some things with Unix Epoch time. iCal wanted an argument in minutes after the current time, which was easy to do, because of the convience of Unix Epoch Time. Honestly is there a better way to express time? (Clearly seconds since the advent of unix, in 1970 January, is superior to all other ways of telling time.) So essentially I took the code for the signing in of Gaucomole,(the API for avocado.io), and then made some sort of ham fisted half ass post. And what I was left with is the script below, which works, with plenty of errors. So after all was said in done, I created an alias to the script, called todo. Letting me now set an alarm in iCal as well as a date in avocado, by typing: todo 02/02/13 13 "Reminder - Therapy on Friday" which is: php -c /etc/php.ini.default reminder.php: todo The date of when you want the next alarm: 02/02/13 February 2nd, 2013, then the hour of that day, using military time so 1 for 1 am and 12 for noon, 13 for 1 pm. 1 pm: 13 Then a description of the event in quotes: "Reminder - Therapy on Friday" It's funky, it's ugly, the php is bad, the applescript is abysmal, the fact it works is a miracle, and clearly a very real indicator that my mind, is full of disease.
<?php

define("_AVOCADO_API_URL_BASE", "https://avocado.io/api/");
define("_AVOCADO_API_URL_LOGIN", _AVOCADO_API_URL_BASE . "authentication/login");
define("_AVOCADO_API_URL_COUPLE", _AVOCADO_API_URL_BASE . "couple");
define("_AVOCADO_COOKIE_NAME", "user_email");
define("_AVOCADO_USER_AGENT", "Avocado Test Api Client v.1.0");

$date = $argv[1];
$military = $argv[2] * 60;
$name = $argv[3];
if (preg_match('/^\d{1,2}\/\d{1,2}\/\d{4}$/', $date)) { 
 $seconds = strtotime($date);
 $milliseconds = $seconds * 1000;
 $minutes_to_add = (($seconds - time()) / 60) + $military;
}
echo $minutes_to_add;
$two_more = $minutes_to_add + 2;
$two_more_milli = ($seconds + 120) * 1000;
$appscript = "<<END
set now to (current date)
 set eStart to now + $minutes_to_add * minutes
 set eEnd to now + $two_more * minutes
 set eName to \" $name \"
 set alarmTime to 0 -- alarm at the exact moment of the event

 tell application \"iCal\"
  set newEvent to make new event at end of events of calendar \"Home\" with properties {summary:eName, start date:eStart, end date:eEnd}
   make new display alarm at end of display alarms of newEvent with properties {trigger interval:alarmTime}
   end tell
END";

`osascript $appscript`;
echo "he";
// Comment these out if you don't want to use this as a command-line script.
$api = new AvocadoAPI();
$api->updateFromCommandLineInput();
$api->createReminder($milliseconds, $two_more_milli, $name);
class AvocadoAPI {
  var $couple,
      $authManager;

  function AvocadoAPI() {
    $this->authManager = new AvocadoAuthManager();
  }

  function updateFromCommandLineInput() {
    $this->authManager->updateAuthFromCommandLineInput();
    $this->updateCouple();

    # Check that the response from the Avocado API was valid.
    if ($this->couple == null) {
      print "FAILED.  Signature was tested and failed. Try again and check the auth information.\n";
    } else {
      print "SUCCESS.\n\nBelow is your Avocado API signature:\n" .
        $this->authManager->signature . "\n";
    }
  }
  function getCouple(){
//  $qry_str = "?avosig=".$this->authManager->signature;
  $ch = curl_init();

  // Set query data here with the URL
  curl_setopt($ch, CURLOPT_URL, _AVOCADO_API_URL_BASE."calendar");
  $this->signCurlRequest($ch);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, '3');
  $content = trim(curl_exec($ch));
  curl_close($ch);
  $content = json_decode($content);
  print_r($content);
  }
  function createReminder($milliseconds, $two_more_milli, $name){
//  $qry_str = "?avosig=".$this->authManager->signature;
   $ch = curl_init(_AVOCADO_API_URL_BASE."calendar");
  $fields = array (
  "start" => urlencode($milliseconds),
  "end" => urlencode($two_more_milli),
  "title" => urlencode($name),
  "location" => '',
  "description" => urlencode($name),
  "timezone" => "America/Chicago"
  );
    curl_setopt($ch, CURLOPT_POSTFIELDS,  $fields);
 curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, _AVOCADO_USER_AGENT);
  $this->signCurlRequest($ch);

 $returndata = curl_exec ($ch);
  curl_close($ch);

  //  $content = json_decode($content);
//  print_r($content);
 echo $returndata;
    $this->createdReminder = $response_code == 200 ? json_decode($output) : null;
 echo $this->createdReminder;
  }

  
  function updateCouple() {
    # Send the POST request.
    $ch = curl_init(_AVOCADO_API_URL_COUPLE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  //  $this->signCurlRequest($ch);
    $output = curl_exec($ch);
    $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    # Use the HTTP response code to test if a valid API request was made.
    $this->couple = $response_code == 200 ? json_decode($output) : null;
  }

  function signCurlRequest($ch) {
    curl_setopt($ch, CURLOPT_COOKIE, _AVOCADO_COOKIE_NAME . "=" . $this->authManager->cookie);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-AvoSig: " . $this->authManager->signature));
    curl_setopt($ch, CURLOPT_USERAGENT, _AVOCADO_USER_AGENT);
  }
}


class AvocadoAuthManager {
  var $cookie,
      $developer_id,
      $developer_key,
      $email,
      $password,
      $signature;

  function AvocadoAuthManager() {}

  function updateAuthFromCommandLineInput() {
    # Ask the user for all of the necessary authentication info
    $this->email = 'your@email.com';
    $this->password = 'yourpassword';
    $this->developer_id = 43;
    $this->developer_key = 'Yourdevkey';
    $this->updateSignature();
  }

  function updateSignature() {
    # Get a new cookie by logging into Avocado.
    $this->updateLoginCookie();

    # Hash the user token.
    $hashed_user_token = hash("sha256", $this->cookie . $this->developer_key);

    # Store the new signature.
    $this->signature = $this->developer_id . ":" . $hashed_user_token;
  }

  function updateLoginCookie() {
    $fields = array(
      'email'=>urlencode($this->email),
      'password'=>urlencode($this->password)
    );

    # Send the POST request.
    $ch = curl_init(_AVOCADO_API_URL_LOGIN);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS,  get_querystring_from_array($fields));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, _AVOCADO_USER_AGENT);
    $header = substr(curl_exec($ch), 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
    curl_close($ch);

    # Store the cookie for use in later API requests.
    $this->cookie = get_cookie_from_header($header, _AVOCADO_COOKIE_NAME);
  }
}


#-----------------------------------------------------
# Mama's little helpers: functions we needed for this.
#-----------------------------------------------------

function get_querystring_from_array($fields) {
  foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
  rtrim($fields_string, '&');
  return $fields_string;
}

function get_cookie_from_header($header, $cookie_name) {
  preg_match('/^Set-Cookie: ' . $cookie_name . '=(.*?);/m', $header, $cookie_array);
  return $cookie_array[1];
}

function get_input_silently($msg){
  # NOTE: stty only works on *nix systems.
  system('stty -echo');
  $input = get_input("Password");
  system('stty echo');
  print "\n";
  return $input;
}

function get_input($msg){
  fwrite(STDOUT, "$msg: ");
  return trim(fgets(STDIN));
}

?>

Thursday, January 3, 2013

Butterfly labs Preorder list sorted by name, rather than date

Someone on bitcointalk noticed that there were starting to be lots of doubles on the pre-order list, so I sorted them by name so you can see who has doubles.


Originally I got the list from here: Forums List

BOW BEFORE MY WASTED YOUTH…I MEAN SUPERIOR REGEXING SKILL:

User:Date Paid:Order Number:Trade-In (Y/N):Qty SC Jalapeno:Qty SC Little Single :Qty SC Single:Qty SC Mini Rig:Wait Time::User

(PIMP) :06/23/2012:1674:Y:0:0:8:0:-:Philj:(PIMP)
2GOOD :07/06/2012:-:N:0:1:0:0:-:2GOOD
2weiX :06/30/2012:2658:N:0:1:0:0:-:2weiX
420session :08/31/2012:6933:N:0:1:0:0:-:420session
6886 :10/24/2012:11682:N:1:0:0:0:-:6886
Aahzman :09/26/2012:9311:N:2:0:0:0:-:Aahzman
Acejam :07/26/2012:3980:N:0:0:4:0:-:Acejam
Akido :09/14/2012:8012:N:0:0:1:0:-:Akido
Akido :09/19/2012:8729:N:0:0:1:0:-:Akido
Alex AXe :07/04/2012:2807:N:1:0:0:0:-:Alex AXe
Atroxes :08/06/2012:4615:N:1:0:0:0:-:Atroxes
Aurics :08/03/2012:4423:N:0:0:1:0:-:Aurics
Azrael_PT :07/24/2012:3865:N:1:0:0:0:-:Azrael_PT
BMF (usagi) :09/11/2012:7839:N:1:0:0:0:-:BMF (usagi)
BMF (usagi) :09/13/2012:7971:N:0:0:1:0:-:BMF (usagi)
BMF (usagi) :09/19/2012:8670:N:1:0:0:0:-:BMF (usagi)
BTC-engineer :06/25/2012:2101:Y:0:0:2:0:-:BTC-engineer
BTC-engineer :06/28/2012:2430:N:0:0:2:0:-:BTC-engineer
BTC-engineer :08/01/2012:4260:N:0:0:2:0:-:BTC-engineer
BTC-engineer :08/04/2012:4494:N:0:0:2:0:-:BTC-engineer
Billington.mark :06/23/2012:1716:N:1:0:0:0:-:Billington.mark
BitMinerN8 :06/23/2012:1676:Y:0:0:4:0:-:BitMinerN8
BitMinerN8 :06/23/2012:1688:N:1:0:0:0:-:BitMinerN8
BitMinerN8 :06/23/2012:1691:Y:0:0:1:0:-:BitMinerN8
BlackPrapor :06/24/2012:1710:Y:0:0:0:2:-:BlackPrapor
BrimStone :06/23/2012:1817:N:-:-:-:-:-:BrimStone
BrimStone :06/28/2012:1817:Y:0:0:1:0:-:BrimStone
BrimStone :06/29/2012:2456:N:0:0:1:0:-:BrimStone
ChipGeek :08/08/2012:-:Y:0:0:1:0:-:ChipGeek
Chomp :08/16/2012:5515:N:0:0:2:0:-:Chomp
Chomp :08/24/2012:6148:N:1:1:0:0:-:Chomp
Crazyates :07/16/2012:3347:Y:0:0:1:0:-:Crazyates
Dargo :06/23/2012:1697:N:0:1:0:0:-:Dargo
Davincij15 :06/24/2012:1864:Y:0:0:3:0:-:Davincij15
Davincij15 :10/16/2012:11139:N:0:0:0:1:-:Davincij15
Davincij15 :10/18/2012:12466:N:3:0:0:0:-:Davincij15
Davincij15 :11/01/2012:12204:N:0:0:2:0:-:Davincij15
Deafboy :09/23/2012:9037:N:3:0:0:0:-:Deafboy
DiCE1904 :09/02/2012:-:N:2:0:0:0:-:DiCE1904
DrG :06/23/2012:1799:N:0:0:2:0:-:DrG
Eveofwar :08/09/2012:4923:N:2:0:0:0:-:Eveofwar
Fcx35x10 (Friend of) :09/07/2012:7476:N:1:0:0:0:-:Fcx35x10 (Friend of)
Fcx35x10 (Friend of) :09/23/2012:9116:N:0:0:1:0:-:Fcx35x10 (Friend of)
Fcx35x10 :09/06/2012:7431:N:0:0:1:0:-:Fcx35x10
Fcx35x10 :10/07/2012:10462:N:0:0:1:0:-:Fcx35x10
Fefox :06/23/2012:1772:Y:0:0:0:2:-:Fefox
Fefox :06/23/2012:1779:Y:0:0:3:0:-:Fefox
Fefox :06/25/2012:2125:N:1:0:0:0:-:Fefox
Garr255 :06/23/2012:1656:N:1:0:0:0:-:Garr255
Grouver :07/08/2012:2977:N:0:0:3:0:-:Grouver
Hfertig :08/05/2012:4574:N:1:0:0:0:-:Hfertig
InfiniTcell :09/01/2012:6973:Y:0:0:1:0:-:InfiniTcell
Insu Dra :08/27/2012:6300:N:1:0:2:0:-:Insu Dra
Iztrojan :09/18/2012:8658:N:0:1:0:0:-:Iztrojan
JWU42 :06/23/2012:1718:Y:0:0:0:1:-:JWU42
JWU42 :06/23/2012:1749:Y:0:0:2:0:-:JWU42
JWU42 :06/23/2012:1783:Y:0:0:4:0:-:JWU42
JackRabiit :10/25/2012:11757:N:1:0:0:0:-:JackRabiit
Jebus :07/02/2012:2642:Y:0:0:1:0:-:Jebus
Jebus :08/21/2012:5520:N:0:0:3:0:-:Jebus
Joshwaa :08/08/2012:4769:N:0:0:1:0:-:Joshwaa
Joshwaa :08/14/2012:5210:N:0:0:1:0:-:Joshwaa
K1773R :09/26/2012:9333:N:1:0:0:0:-:K1773R
KIDC :06/23/2012:1806:Y:0:0:6:0:-:KIDC
Keefe :06/23/2012:1700:N:0:0:2:0:-:Keefe
Keefe :06/23/2012:1846:N:1:0:0:0:-:Keefe
Khanduras :08/03/2012:4443:N:1:0:0:0:-:Khanduras
Kjlimo :07/06/2012:-:N:0:0:1:0:-:Kjlimo
Kjlimo :07/06/2012:-:Y:0:0:3:0:-:Kjlimo
Korbman :08/16/2012:5467:N:1:0:0:0:-:Korbman
KyleH :06/30/2012:2548:N:0:0:1:0:-:KyleH
KyleH :07/15/2012:3316:N:0:0:1:0:-:KyleH
LLight :06/25/2012:2043:N:1:0:0:0:-:LLight
LWCoder :06/24/2012:1931:Y:0:0:1:0:-:LWCoder
LWCoder :06/24/2012:1933:N:1:0:0:0:-:LWCoder
LivTru :07/05/2012:2675:Y:0:0:0:1:-:LivTru
LivTru :07/07/2012:2943:Y:0:0:1:0:-:LivTru
LivTru :08/16/2012:5502:Y:0:0:1:0:-:LivTru
Lotus :09/15/2012:8233:N:2:0:0:0:-:Lotus
Maidak :09/14/2012:8157:N:1:0:0:0:-:Maidak
Maidak :10/10/2012:10662:Y:0:0:1:0:-:Maidak
Mapuo :08/12/2012:5049:Y:1:0:0:0:-:Mapuo
MichaelBliss :08/17/2012:5617:Y:0:0:1:0:-:MichaelBliss
Michail1 :06/26/2012:1751:Y:0:0:0:1:-:Michail1
Miner99er :06/24/2012:1918:N:1:0:0:0:-:Miner99er
MooC Tals :10/12/2012:10833:N:0:0:1:0:-:MooC Tals
Mooc Tals :10/10/2012:10706:N:0:1:0:0:-:Mooc Tals
MoonShad0w384 :06/24/2012:2062:N:4:0:0:0:-:MoonShad0w384
Mushroomized :07/15/2012:3340:N:1:0:0:0:-:Mushroomized
NLA :10/19/2012:11113:N:0:0:0:1:-:NLA
OgNasty :06/23/2012:1657:Y:0:0:6:0:-:OgNasty
OgNasty :06/23/2012:1670:N:1:0:0:0:-:OgNasty
OgNasty :07/24/2012:3899:N:0:0:1:0:-:OgNasty
OgNasty :07/24/2012:3900:N:0:0:1:0:-:OgNasty
OmegaNemesis28 :07/09/2012:3063:N:-:-:-:-:-:OmegaNemesis28
OmegaNemesis28 :07/13/2012:3063:N:0:0:1:0:-:OmegaNemesis28
P!nk4sand :06/23/2012:-:N:0:0:3:0:-:P!nk4sand
Photon939 :06/27/2012:2293:N:2:0:0:0:-:Photon939
Phraust :06/23/2012:1715:Y:0:0:5:0:-:Phraust
Pinwheel :07/05/2012:2831:N:0:0:1:0:-:Pinwheel
RATM69 :10/15/2012:10811:N:0:0:2:0:-:RATM69
RATM69 :10/24/2012:11663:N:0:0:2:0:-:RATM69
SLok :08/05/2012:-:N:0:0:1:0:-:SLok
SgtMoth :08/11/2012:4996:N:1:0:0:0:-:SgtMoth
SgtMoth :09/06/2012:7357:N:1:0:0:0:-:SgtMoth
SgtMoth :09/19/2012:8685:N:1:0:0:0:-:SgtMoth
Shirik :06/23/2012:1706:N:2:0:0:0:-:Shirik
SimBesh :07/18/2012:3483:N:0:0:2:0:-:SimBesh
Soros Shorts :06/27/2012:2355:Y:0:0:1:0:-:Soros Shorts
Soros Shorts :08/31/2012:6936:Y:0:0:1:0:-:Soros Shorts
Soros Shorts :09/01/2012:6977:N:1:0:0:0:-:Soros Shorts
Soros Shorts :09/05/2012:7325:Y:0:0:1:0:-:Soros Shorts
Soros Shorts :09/14/2012:8116:N:0:0:1:0:-:Soros Shorts
Starlightbreaker :07/01/2012:2593:N:1:0:0:0:-:Starlightbreaker
Subo1978 :08/02/2012:4272:N:1:0:0:0:-:Subo1978
Subo1978 :09/19/2012:8639:N:0:0:1:0:-:Subo1978
SupaDupa :11/08/2012:12589:N:1:0:0:0:-:SupaDupa
Tachikoma :06/23/2012:1686:N:2:0:0:0:-:Tachikoma
TechCF :08/05/2012:4571:N:1:0:0:0:-:TechCF
Testit :08/13/2012:5177:N:5:0:0:0:-:Testit
The Joint :06/23/2012:1769:N:3:0:0:0:-:The Joint
Toresh :10/18/2012:11048:N:0:1:0:0:-:Toresh
Unacceptable :06/24/2012:1825:N:0:1:0:0:-:Unacceptable
UnderGod :09/13/2012:7978:N:1:0:0:0:-:UnderGod
Xian01 :06/24/2012:2030:N:0:0:1:0:-:Xian01
Xian01 :06/25/2012:2158:Y:0:0:1:0:-:Xian01
Zeek_W :10/04/2012:10170:N:1:0:0:0:-:Zeek_W
aigeezer :07/07/2012:2951:N:0:1:0:0:-:aigeezer
asdlsd :07/01/2012:2595:N:2:0:0:0:-:asdlsd
avidreader :07/18/2012:3540:N:0:0:0:2:-:avidreader
avidreader :07/20/2012:3621:N:3:0:0:0:-:avidreader
avidreader :07/24/2012:3724:N:0:0:3:0:-:avidreader
bitarrow :08/13/2012:5175:N:0:0:0:2:-:bitarrow
bitboyben :07/03/2012:2764:N:1:0:0:0:-:bitboyben
bitboyben :10/22/2012:11078:N:3:0:0:0:-:bitboyben
bitcoindaddy :06/27/2012:2363:N:0:0:1:0:-:bitcoindaddy
bitcoindaddy :06/28/2012:2442:N:0:0:1:0:-:bitcoindaddy
bitcoindaddy :07/04/2012:2777:N:1:0:0:0:-:bitcoindaddy
bitgirl :08/01/2012:4256:N:0:0:3:0:-:bitgirl
bonks :07/02/2012:2682:Y:0:0:2:0:-:bonks
bpd :07/01/2012:2624:N:1:0:0:0:-:bpd
bsdpunk :09/01/2012:6997:N:1:0:0:0:-:bsdpunk
bsdpunk :11/10/2012:12735:N:1:0:0:0:-:bsdpunk
burger :09/25/2012:9252:N:2:0:0:0:-:burger
chrisrico :07/16/2012:3421:N:1:0:0:0:-:chrisrico
crazyates :06/23/2012:-:Y:4:0:0:0:-:crazyates
dankroxel :06/26/2012:2150:N:0:0:3:0:-:dankroxel
dankroxel :08/09/2012:4886:N:0:0:3:0:-:dankroxel
dargo :06/23/2012:1679:N:0:0:1:0:-:dargo
dave3 :06/24/2012:1801:Y:0:0:2:0:-:dave3
davidspitzer :07/11/2012:3146:Y:8:0:0:0:-:davidspitzer
davidspitzer :07/11/2012:3147:Y:0:0:10:0:-:davidspitzer
davincij15 :09/06/2012:7423:N:0:0:3:0:-:davincij15
dickcheney :06/23/2012:1773:N:5:0:2:0:-:dickcheney
dust :06/25/2012:-:Y:0:0:0:1:-:dust
dyingdreams :07/26/2012:3976:N:1:0:0:0:-:dyingdreams
fatpan :07/22/2012:3758:N:2:0:0:0:-:fatpan
firefop :08/08/2012:4527:Y:0:0:1:0:-:firefop
freshzive :06/29/2012:2498:Y:0:0:1:0:-:freshzive
fulepp :06/29/2012:2360:Y:0:0:0:1:-:fulepp
fuxianhui888 :06/23/2012:1684:Y:0:0:2:0:-:fuxianhui888
fuxianhui888 :08/02/2012:4364:N:0:0:0:1:-:fuxianhui888
gades :09/27/2012:9424:N:1:0:0:0:-:gades
gigavps :06/23/2012:-:Y:0:0:0:4:-:gigavps
gtrrkicw :08/31/2012:6883:N:1:0:0:0:-:gtrrkicw
hacknoid :07/11/2012:3004:N:0:0:2:0:-:hacknoid
hakock :06/27/2012:1972:Y:0:0:1:0:-:hakock
happyland :08/16/2012:5511:N:0:0:2:0:-:happyland
hashalfahalve :09/04/2012:7119:Y:0:0:2:0:-:hashalfahalve
hausmarke :06/28/2012:-:Y:0:0:2:0:-:hausmarke
iztrojan :09/19/2012:8658:N:2:0:0:0:-:iztrojan
iztrojan :09/20/2012:8818:N:1:0:0:0:-:iztrojan
iztrojan :09/27/2012:9322:N:1:0:0:0:-:iztrojan
jojo69 :08/03/2012:4028:N:0:0:1:0:-:jojo69
jorgen :10/04/2012:10127:Y:0:0:1:0:-:jorgen
juggalodarkclow :06/28/2012:2473:Y:8:0:0:0:-:juggalodarkclow
kaneda2004 :06/27/2012:2176:N:0:0:1:0:-:kaneda2004
katie.mckinley :09/14/2012:8087:N:1:0:0:0:-:katie.mckinley
kibblesnbits :06/23/2012:1821:Y:0:0:1:0:-:kibblesnbits
kjlimo :06/24/2012:1870:Y:0:0:1:0:-:kjlimo
kjlimo :08/31/2012:6296:N:0:0:6:0:-:kjlimo
kjlimo :10/24/2012:11447:Y:0:0:4:0:-:kjlimo
kreal :06/24/2012:1964:N:0:0:1:0:-:kreal
kroneko :08/01/2012:4241:N:1:0:0:0:-:kroneko
kroneko :08/04/2012:4479:N:0:0:1:0:-:kroneko
kslavik :09/05/2012:7058:N:1:0:0:0:-:kslavik
kslavik :09/05/2012:7059:N:1:0:0:0:-:kslavik
kslavik :10/08/2012:10503:N:0:1:0:0:-:kslavik
laSeek :09/21/2012:8779:N:1:0:0:0:-:laSeek
leofar :06/24/2012:-:N:0:0:1:0:-:leofar
leofar :06/24/2012:1835:N:0:0:1:0:-:leofar
leofar :06/25/2012:1848:Y:0:0:3:0:-:leofar
leofar :06/30/2012:2451:Y:0:0:2:0:-:leofar
leofar :07/04/2012:2731:N:0:0:1:0:-:leofar
leofar :07/18/2012:3448:N:4:0:0:0:-:leofar
melco :07/02/2012:2194:N:0:0:2:0:-:melco
mentalove :07/02/2012:2423:N:0:0:1:0:-:mentalove
michaelmclees :08/28/2012:6314:N:1:0:0:0:-:michaelmclees
michaelmclees :08/29/2012:6637:N:0:1:0:0:-:michaelmclees
midnight :08/16/2012:5422:N:0:0:2:0:-:midnight
mightygoose :07/02/2012:2229:N:1:0:0:0:-:mightygoose
mikebob :06/23/2012:1714:N:1:0:0:0:-:mikebob
mikebob :06/23/2012:1722:Y:0:0:1:0:-:mikebob
mikeo :07/09/2012:3017:N:0:0:1:0:-:mikeo
mindphlux :06/23/2012:1838:N:0:0:9:0:-:mindphlux
miner3gazillionand8 :08/08/2012:4843:N:4:0:0:0:-:miner3gazillionand8
mitak64 :09/11/2012:7782:Y:0:0:1:0:-:mitak64
mitak64 :09/14/2012:8085:Y:0:0:1:0:-:mitak64
mohawk38 :07/17/2012:3226:N:0:0:1:0:-:mohawk38
mohawk38 :07/19/2012:3430:Y:0:0:1:0:-:mohawk38
mokahless :06/24/2012:1842:N:1:0:0:0:-:mokahless
monstrs :09/24/2012:9144:N:0:1:0:0:-:monstrs
mufa23 :08/27/2012:6386:N:1:0:0:0:-:mufa23
murasha :08/28/2012:6419:N:1:0:0:0:-:murasha
nedbert9 :07/17/2012:3295:Y:0:0:5:0:-:nedbert9
nedbert9 :07/19/2012:3626:Y:0:0:2:0:-:nedbert9
nederhoed :08/06/2012:4646:N:0:0:1:0:-:nederhoed
nederhoed :08/26/2012:6276:N:0:0:1:0:-:nederhoed
nederhoed :08/31/2012:6872:N:0:0:1:0:-:nederhoed
neiros :07/05/2012:2833:N:2:0:0:0:-:neiros
ninjaboon :08/15/2012:5284:N:2:0:0:0:-:ninjaboon
nomorecoin :08/05/2012:4565:N:0:1:0:0:-:nomorecoin
nomorecoin :10/04/2012:10169:N:1:0:0:0:-:nomorecoin
owdbetts :07/21/2012:3734:Y:0:0:1:0:-:owdbetts
phantitox :06/24/2012:2015:N:2:0:0:0:-:phantitox
psilan :06/28/2012:-:Y:0:0:1:0:-:psilan
pyromaniac :09/21/2012:8852:N:3:0:0:0:-:pyromaniac
ragnard :06/28/2012:2469:N:0:1:0:0:-:ragnard
real1510 :07/01/2012:2596:N:0:1:0:0:-:real1510
rjk :06/23/2012:1776:N:2:0:0:0:-:rjk
runlinux :06/23/2012:1824:N:1:0:0:0:-:runlinux
salfter :08/29/2012:6535:N:2:0:0:0:-:salfter
server :06/25/2012:2065:N:0:1:0:0:-:server
server :06/29/2012:2278:N:1:0:0:0:-:server
sexystick :07/05/2012:2741:N:0:0:2:0:-:sexystick
sexystick :08/21/2012:5912:N:0:0:2:0:-:sexystick
sgravina :06/24/2012:1814:N:0:0:0:0:-:sgravina
sgravina :07/13/2012:3242:N:0:0:1:0:-:sgravina
sickstarr :06/25/2012:2133:Y:16:0:0:0:-:sickstarr
sickstarr :06/25/2012:2137:Y:8:0:0:0:-:sickstarr
sickstarr :06/25/2012:2139:Y:8:0:0:0:-:sickstarr
smartlight :08/31/2012:6864:N:2:0:0:0:-:smartlight
somenick :06/25/2012:2119:Y:0:0:10:0:-:somenick
somenick :06/25/2012:2121:Y:0:0:6:0:-:somenick
somenick :08/06/2012:4626:Y:0:0:1:0:-:somenick
somenick :08/09/2012:4891:N:0:0:0:1:-:somenick
soniq :08/27/2012:6464:N:2:0:0:0:-:soniq
sysrun :06/23/2012:-:N:8:0:0:0:-:sysrun
tarrant_01 :07/09/2012:3028:Y:0:0:1:0:-:tarrant_01
tbcoin :08/16/2012:-:N:0:0:1:0:-:tbcoin
tbcoin :10/01/2012:-:N:0:0:0:1:-:tbcoin
tonto :10/18/2012:11302:N:1:0:0:0:-:tonto
tytus :08/18/2012:-:Y:0:0:0:1:-:tytus
uck :06/26/2012:2299:Y:0:0:1:0:-:uck
uck :08/08/2012:4839:Y:0:0:2:0:-:uck
uck :08/12/2012:5107:Y:0:0:0:1:-:uck
urlord :09/12/2012:7906:N:1:0:0:0:-:urlord
vapourminer :06/24/2012:1851:N:1:0:0:0:-:vapourminer
vom :07/29/2012:4093:N:1:0:0:0:-:vom
vom :08/03/2012:4446:N:1:0:0:0:-:vom
wksantiago :09/22/2012:9000:N:1:0:0:0:-:wksantiago
xxaudioxx :06/23/2012:1727:N:0:0:4:0:-:xxaudioxx
xxaudioxx :06/24/2012:1734:N:1:0:0:0:-:xxaudioxx
xxaudioxx :07/03/2012:2708:N:5:0:0:0:-:xxaudioxx
xxaudioxx :07/04/2012:2787:N:0:0:2:0:-:xxaudioxx
yogafan :07/19/2012:3550:N:3:0:0:0:-:yogafan
zikeji :10/11/2012:10797:N:1:0:0:0:-:zikeji

Using Applescript to lauch several terminal tabs with ssh

This is an applescript that will launch your terminal and go ahead and get you logged into several ssh sessions in tabs. I wrote this...or rather cannabalized somebody else's script, when I was a sys admin and programmer, I needed to be sshed into several machines at the beginning of work. I thought that if I used scripts like this I would end up saving time in the long run.

This actually turned out not to be true, but through no fault of my own. It turned out that the e-commerce book store that I was working for was getting over ninety percent of there sells from a single book, that relied on a single link referral. And they pulled the link referral because the place that I worked for, was constantly late delivering the book. Never trust a company with Christian in their name.

You will need to change "root" to be your user and the domain names to be your domain names. If you have ssh keys set up, you should be good to go. Otherwise you will have to manually type or paste your password in.

Occasionally a ball-peen hammer hits me in the head and I forget how to set up ssh keys, if this happened to you, you can use this link to remind yourself. HowTo Ssh Keys

set user to "root"
set theHost to "mechanicalpinata.com"

activate application "Terminal"

tell application "System Events"
 tell process "Terminal"
  keystroke "t" using command down
 end tell
end tell

delay 1 -- it seems we need this

tell application "Terminal"
 do script "ssh " & user & "@" & theHost in the last tab of window 1
end tell

set user to "root"
set theHost to "YourOtherDomainNameOrIP.com"

activate application "Terminal"

tell application "System Events"
 tell process "Terminal"
  keystroke "t" using command down
 end tell
end tell

delay 1 -- it seems we need this

tell application "Terminal"
 do script "ssh " & user & "@" & theHost in the last tab of window 1
end tell

Tuesday, January 1, 2013

TamperMonkey / GreaseMonkey Script

In an attempt to make r/minimalism a little...less cluttered, I wrote this tampermonkey/greasemonkey script, would like to add more but I haven't figured our just what yet. Would love to see if anyone has any improvement. This is more of an effort to get the ball rolling than an actual attempt at reskinning, you guys have better eyes than me.

// ==UserScript==
// @name       r/minimalism
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  Minimizing Minimalism
// @match      http://www.reddit.com/r/minimalism/
// @copyright  2012+, You
// ==/UserScript==
var $ = unsafeWindow.jQuery;
$('.domain').each(function (){
if (/self\.minimalism/.test($(this).html())){
  $(this).html('(self)');
} 
}
                 );
$('.tagline').each(function (){
if (/(hour|minute)/.test($(this).html())){
  $(this).html('submitted recently');
}
}
                  );
$('#siteTable').attr("align","center");

Sunday, April 8, 2012

Proprietary Unix


20:04 < Zed> bsd, unfortunately these proprietary unices get kinda mad trying to install some packages from a different version.
20:04 < Zed> my 6.5.0 cd set lets me use the freeware folder but not the Foundations or Development cds
20:07 < bsdpunk> That sounds like a terrible medieval title
20:07 ::: Grafkanker [Grafkanker@mvg-20AEBDC2.dynamic.caiway.nl] has joined #chats
20:07 < bsdpunk> like a guy with no balls who enforces copyright law
20:07 < bsdpunk> Proprietary Eunuch
20:08 < Zed> lol


In reference to Irix.

Sunday, July 31, 2011

Modified PHP bot for trading bitcoins on mtgox

General information about bitcoins (mtgox, mining, etc) here: http://bsdpunk.blogspot.com/2011/07/bitcoins-bitcoins-bitcoins.html

I've been messing around with bitcoin, and I found a bot at :
http://bitklein.com/bot.php

What I did was minimize the bot, and change it so it buys bit coins if they are less than 15 dollars, and I have over 60 bucks in my MtGox account.
If the bitcoins become worth over 24 dollars, sell all of them. I also have the mtgox bitcoin app on my phone in case I need to dump them.

function mtgox_query($path, array $req = array()) { 
   $key='yourkey';      //<----KEY! 
   $secret='yoursecret';   //<-SECRET! 
    
                   $mt = explode(' ', microtime()); 
                   $req['nonce'] = $mt[1].substr($mt[0], 2, 6); 
                   $post_data = http_build_query($req, '', '&'); 
                   $headers = array( 
                          'Rest-Key: '.$key, 
                          'Rest-Sign: '.base64_encode(hash_hmac('sha512', $post_data, base64_decode($secret), true)), 
                  ); 
                  static $ch = null; 
                  if (is_null($ch)) { 
                          $ch = curl_init(); 
                          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
                         curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); 
                  } 
                  curl_setopt($ch, CURLOPT_URL, 'https://mtgox.com/api/'.$path); 
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
                  $res = curl_exec($ch); 
                  if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch)); 
                  $dec = json_decode($res, true); 
                  if (!$dec) throw new Exception('Invalid data received, please ma 
  ke sure connection is working and requested API exists'); 
          return $dec; 
          } 
  $decoded=mtgox_query('0/getOrders.php?since=0'); 
  var_dump($decoded); 
  //print_r($decoded); 
 $seconds_wait = 40; 
  $truth =  TRUE; 
  while($truth){ 
          sleep($seconds_wait); 
          echo "----------------------------------------\n"; 
          $r=mtgox_query('0/getFunds.php'); 
          echo "USD TOTAL: ".$r['usds']."\n"; 
          echo "BTC TOTAL: ".$r['btcs']."\n\n"; 
          $decoded=mtgox_query('0/data/ticker.php'); 
  //      echo date('l jS \of F Y h:i:s A')."\n"; 
          echo "LAST:".$cur_last=$decoded['ticker']['last']."\n"; 
          echo "BUY:".$cur_buy=$decoded['ticker']['buy']."\n"; 
          echo "SELL:".$cur_sell=$decoded['ticker']['sell']."\n"; 
          echo "HIGH:".$cur_high=$decoded['ticker']['high']."\n"; 
          echo "AVERAGE:".$cur_avg=$decoded['ticker']['avg']."\n"; 
          echo "VWAP:".$cur_vwap=$decoded['ticker']['vwap']."\n\n"; 
   
  if(($r['usds'] > 60) && ($cur_buy < 15) ){ 
                  $amount= ($r['usds'] / $cur_buy); 
                  $amount = number_format($amount, 2, '.', ''); 
                  $price=$cur_buy; 
                  echo " PRICE: $price AMOUNT: $amount"; 
                  echo "Buying Bit coins to cancel transaction hit Ctrl C\n"; 
                  sleep(30); 
                  $req=array('amount'=>$amount,'price'=>$price); 
                  $decoded=mtgox_query('0/buyBTC.php',$req); 
                  echo "STATUS: ".$decoded['status']."\n"; 
  }                                
          if($cur_sell > 24 ){ 
                  echo "Selling Bitcoins\n"; 
                  $price = $cur_sell; 
                  $amount = $r['btcs']; 
                  $req=array('amount'=>$amount,'price'=>$price); 
                  $decoded=mtgox_query('0/sellBTC.php',$req); 
                  echo "STATUS: ".$decoded['status']."\n"; 
                  $truth = FALSE; 
          } 
  } 




You can get information about mtgox's api here, and about the bot: http://bsdpunk.blogspot.com/2011/07/bitcoin-software-for-mtgoxs-api.html


When I run this script I actually start a screen session, then type: php mtgox.php > mtgox.log
After that I open a terminal window and tail -f mtgox.log

Bitcoin software for mtgox's api

MtGox has this wonderful API: https://mtgox.com/support/tradeAPI

There's also a perl module for MtGox: http://search.cpan.org/~mndrix/Finance-MtGox-0.01/lib/Finance/MtGox.pm

And someone wrote this handy PHP bot, who I promise in the future I will donate some sort of bitcoinage too, because I ripped this thing apart and made my own, but he certainly made my life much easier:
Forum post:
http://forum.bitcoin.org/index.php?topic=31693.msg398512#msg398512
Actual Website to download File:
http://bitklein.com/bot.php

I'll post some of my modifications to the bot some time in the future.

Also if you're really interested in bitcoin mining, I invite you to take a look under the hood of the bitcoin miner poclbm
https://github.com/m0mchil/poclbm

Bitcoins bitcoins bitcoins

I'm going to defcon soon and it seem that there is only one lectrure on bitcoins. This saddens me. I use Mt.Gox to do all my bitcoin transactions. Which is to say convert my bitcoins into DOLLA DOLLA DOLLA bills. I am somewhat proud and somewhat ashamed to admit I am a bitcoin miner. As of right now I don't have any winning tips for you on how to be a miner. I will however introduce you to them.

Go here if you want to read the real version of what they are and how they work, instead of my dramaticized half fictional account: http://en.wikipedia.org/wiki/Bitcoin

Bitcoins are a currency based on cryptography, using various mathmatics to prevent shenanigans. Bitcoin miners, people who provide proof of work, for the bitcoins, can actually aquire bitcoins. And bitcoins can be turned into dolla dolla dolla bills. So to do this proof of work you rent out your proccessor, ok really you need to rent out your graphics card: ( https://en.bitcoin.it/wiki/Mining_hardware_comparison )

Woah Woah Woah, why are all the cards ATI..., well it turns out the function mostly used is sha256 and guess what, on ATI cards, there is a specific asm function for that....WAY TO GO Amd.


So get a client to cruch this cryptography and start cracking away. Use poclbm if you got graphics cards on the brain( https://github.com/m0mchil/poclbm ). Now if you want to use CPU's which is by all accounts is at least 50 some odd times slower you can still go for it, use RPCMiner for mac, and minerd for linux. Join a mining pool like deepbit and start crackalackin a way.

If you join a mining pool the rewards can come very fast.......but with very fast, come very small rewards, lol.

CAVEATS:
OH AND ONE HUGE CAVEAT. This will eat electricity like a mother fucker. No joke, if you live in (Worse case US scenario ) Hawaii, have two rigs, with 2 graphics cards a piece your electric bill can go up over 200 dollars what it normally is. LOl that math is bad and terrible. For real math ( http://www.pcper.com/reviews/Graphics-Cards/Bitcoin-Mining-Update-Power-Usage-Costs-Across-United-States ). This also makes crunching solely on cpus, pretty much a no gain death trap, by my understanding.

Updates to Contest and Goings on (Defcon)

If you have a submission for the contest find someway of getting it to me, whether that be bsdpunk at the gmail, or a comment to your github, or whatever your preferred method of delivery is. I'll announce a winner soon.

In other news, I will be at defcon, if you would like to befriend/harass me. So give me a tweetage @bsdpunk if you'd like to meet up.

Sunday, June 12, 2011

#devel contest draft rules

It's contest time again, and more particularly, it's contest time for the #devel channel on irc.malvager.net

Draft Rules for the #devel contest of irc.malvager.net:


Create a tool that will either allow or otherwise encourage people in #devel to collaborate in code writing and or sharing. The platform/language can be any (within reason; if you’re not sure, ask). It will be judged subjectively by both bsdpunk and psycho on both functionality and creativity. The first place prize will be a bsdpunk t-shirt and an Arduino (or Arduino clone). The second place prize is an Arduino (or clone). If god willing a third place prize, tbd (this one is not written in stone).

Contest will be over on the 20th of July.


Draft rules are subject to change for the next week, keep updated by looking at this blog(rules will only change by minor stipulations, the spirit of the contest will remain the same).

Sunday, May 29, 2011

The blog has been around for a wee bit. And will be around for a wee bit more.



I got my first check from google, for running ads on my site. My first blog post, for this particular blog, was on Tuesday, January 22, 2008. That check, is a reflection of from then, until now. I told my girlfriend that I had gotten the check and she said that was cool, and I was like not really, 3 years of work, translated into 73 dollars didn't seem good to me. And asked, well isn't it "free money", from a labor of love?

Hmm… Had to think on this one for a moment. It certainly didn't start out that way. I started writing the blog, thinking I could sell T-shirts and get advertisement revenue, by attracting teenagers with a disposable income. This certainly isn't what happened. If you will waltz down memory lane with me for a paragraph I'd appreciate it.

In the first year, I started it to make money. Which in retrospect was dumb. I got an account on a forum site, hackforums.net. Which turned out to be the right demographic, but people searching for the wrong knowledge base. For the first year that site was 70% of my traffic with the other 20 - 30% coming from google search results. I worked hard to be someone on that site and eventually I was even a moderator for it. I busted my ass that first year, writing the majority of the now 433 posts on this blog, being written in that time. And I tried to sell t-shirts, even had a photo shoot, lol.

I really began exploring other creative mediums as time progressed, the blog gave me a vehicle and confidence to do so. I wrote some, hmmm, would you call it music? Eventually finishing an "EP" which you can still download from last.fm.

I'm doing lot's of other little things. That are various and sundry labors of lover perhaps. In fact I'm microblogging right now at http://ramblings.malvager.net. I do a fiction blog that most certainly is a labor of love. And other side projects that may fall into that category. And another goblin majick album coming up too.

So what is it now, obviously I'm still blogging, and I'm not making money off of it. I've got about 5 posts planned out as of right now, don't know whether they all get released next week or next month. Is it a labor of love? It must certainly isn't. Is it to make money? Of course not. All I can say for sure, is it's a force of habbit.

irc.malvager.net, is my only continuously kept updated labor of love, and for me it's more of a money sync than a labor of love, because two(kye, psycho) of the GREATEST people, and damn good hackers too, help me maintain it, while I just pay a chunk of the server bill. Seriously, love you guys; in the words of Jesse Dangerously, I couldn't make a move without you guys, y'all my legs.

Thursday, April 7, 2011

Last.fm I must leave thee.

I really like last.fm, I like what it keeps track of. That's what I like about it. I don't like it's algo, the math they use to determine what songs you like. Yeah I listened to ICP in the 5th grade...no I don't need every single song I listen to today to be from Psychopathic Records. At one point on my "Reccomended" I could only get comedy because I liked a few comedians tracks, and a lot of nerdcore. ::facepalm::

Do not need.

So I don't care, they keep track of what I'm listening to, that's what I use the service for, and for the create your own station by tag or whatever the option is called. This station only mildly has to do with that tag, which for better or worse is usually better than the radio....wait, not if you live near/in Nashville. We have 91.1...at least for a little while. Losing that station is going to suck.

I digress. So I went to listen on my phone today, to Last.fm and sure enough there's a pay wall for mobile devices now. I did a double take...seriously. I started poking around there website to see what the deal was, and wonderfully enough there is an export in XML format, for your loved tracks.

I took the chance, and indeed Paul Simon was right. I hopped on the Bus Gus. So I grabbed that file. I decided to make it more readable for non geeks, so I did this to put a more readable version in a file called titles:

cat bsdpunk_lovedtracks.xspf |perl -pe "s/.*<title>(.*)<\/title><creator>(.*)<\/creator>.*/Song: \1 Artist: \2/gi"> titles


Yeah yeah I know, don't parse XML with regex, it will anger Chthulu. I still don't know what you are supposed to use to parse it without regex, and even if I did I probably wouldn't use it for this, it took me less than a few minutes to write.

Also does that snippet of code help...no not really. I mean that's to give you something that is human readable to other people, you know...normies, so you have a:

Song: Twenty-Three Artist: MC Lars
Song: Listen Close Artist: MC Frontalot
Song: In Arrears Artist: MC Frontalot
Song: Why So Nerdcore Artist: MC GoblinMajick


What will I ultimately do with this xml file...obviously not this, unless I just wanted to paste it up somewhere like a web page.

I think I actually want to build my own algo. In some way it can be run independently, of pay services that actually provide the music, like last.fm.

How will I do this...I have no idea. It's 4 in the morning, and I have to be at work in a few hours, I just couldn't sleep.

Until then I will use Pandora on my phone( evo shift ). My very awesome phone I am very much in love with(not sarcasm).

Monday, April 4, 2011

Read this, for his name is fishmeal

Success and Farming vs Mining
Read this, and if you don't read it, then the tl;dr I got out of it, is quoted below.


This doesn’t work. Your idea sucks. No, I’m not calling you stupid — my idea sucks, too. All ideas suck, because they are just ideas. They’re worth nothing.

My success is because I worked to make the idea real. A lot. All my life. Starting when I was 12, I learned to program, and I’ve programmed every spare moment since. I didn’t become a millionaire until I’d worked at it for eighteen years. There was no genius idea I had. I just kept working, hating what I did before, and working some more to make it better.


I've been thinking about how I should focus, on what I should be doing, who I should be working for, and what I should be learning. It was nice to have a lighthouse in the fog. I know where I'm headed, but the occasional reminder never hurts.

Thursday, March 31, 2011

Donate to Japan, Keep Checking on GeoHot and Keep it Real programming

I really appreciate this site because the only image is the center one(well the center image is a bunch of images put together), but the rest of the "logos" are randomly created through javascript. http://next.do/, I used the idea, and quite honestly borrowed a lot of the javascript to create something for my girlfriend.

This week though I couldn't afford to give much I did give to one charitable japan cause, one because I like 8 bit music and two because....well there was a god damned earthquake:

http://truechiptilldeath.com/japan/

You get a SHITLOAD of tracks for whatever you donate....if you do donate small like I do, I suggest you also donate the cost of the credit card transaction, the extra 83 cents or whatever isn't going to kill you.

And it looks like the first round of donations for geohot(PS3 hacker) are closed, but keep abreast of the situation Geohot's blog.


And if you need your daily dose of reality, in the programming realm, take a look at this Use your brain.


Ok no more shitty link posts....ever again...I promise...until next month anyway.

Using Javascript in the address bar

One easy way to run javascript in your browser is to, simply type:

javascript: and then a javascript function

So for example, if you want to change the term Christian Business into scams, just paste this into your address bar.

javascript: document.write(document.childNodes[1].innerHTML.replace(new RegExp(/Christian Business/gi), "scams").replace(new RegExp(/Christian Business/gi), "scams"))

To test this you could go here: http://www.google.com/search?hl=en&q=%22Christian+Business%22&aq=f&aqi=g10&aql=&oq=

And then just paste said javascript into the browser bar.

Wednesday, March 30, 2011

The questions and the aftermath

After the interview that changed me from believing I was masterful wizard of the cli, into realizing I was more like Schmendrick before he met the Unicorn. I thought I would share some of the questions, and what I've been doing to improve my knowledge. This isn't a comprehensive list of all the questions as the interview is mostly a blur, as mentioned before I usually knock technical interviews down like dominos. This one I didn't and I can only blame my soft knowledge of linux, which I greatly exaggerated in my own mind. For the sake of brevity, and sort of for accuracy as well, when I got one right he seemed to nod, and write the extent to which I felt the mastered the question down, so I'll say nod for those, and for the ones I got wrong, he just put a tick mark next to that.



Preliminary non Technical Questions


Can you pass a drug test?

Yes.

Are you sure?

Yes.

It's a hair test.

I nodded.

THEY WILL FIND A HAIR.(I'd like to note he did in fact raise his voice)


I'd like to note that during the interview I was pretty "clean" looking. I had shaved, cut my hair, was wearing a shirt and tie, however any other given day perhaps this question would require more than one pass, as I do usually sport long hair and neck beard, wear t-shirts, and generally look of malaise. He could have been reading my body language or he could have just not wanted to deal with a 2 hour technical interview that day, or with someone who he thought wasn't going to pass anyway. I don't know.



He asked if I could pass a credit check.

Yes.
He asked if I could pass a background check.

Yes

The Technical Terror Interview


Like I said these are the questions I remember, as close to the order I remember. The interview was two hours, so obviously quite a few are missing. Also I started by adding that some of the facts on my interview were padded or inaccurate, because my recruiter had rewritten it. I went over these with him so that if necessary we could cancel the interview. However, he didn't seem to mind the areas I was weak in.






Have you ever compiled the linux kernel?


I have it's been longer than 5 years ago, it was for a driver issue or something like that, if I remember correctly. It's been a long time.

nod






What are the tools required to compile the linux kernel?


Like I said it's been a long time, I don't really remember, I'm sure gcc is involved at some point.


tick






Describe the linux boot process after it is handed over from the bios


Note: Panic set in, I lost my shit, why didn't I know this, I know I should know this.

So I hate to admit this but I don't know,if I had to guess it would go to the boot manager, then probably the kernel, then the kernel modules then kudzu at some point maybe.*sigh*


tick




This is probably where the gaps start but I regain conciseness somewhere about 30 minutes-ish later, I know I said something about apache during this time period that seemed to tickle his fancy, but that's about all the good that thirty minutes had



What editor do you use?....Oh well of course I know what you use.

Vim?

I'm guessing it's the only real editor to you?

Well it's my favorite, but I have respect for my emacs brethren

At this point, a calm in the storm, we had an editor conversation where we both seemed to agree on a lot of it. Mostly it was about how to teach those new to vim how to use it. We also did a little nano slamming.




What is a zombie process?

A process that has lost communication with it's parent and probably needs to be killed.

Half Tick, Half Nod, slight writing.


He explained that the parent process to had died and he asked me how to kill it.

Probably a kill -9.

Hmmm...

tick

Just a kill or kill -4






Do you know the difference between kill -9 and kill

I believe a kill -9 is forcing a program to close and a kill is more like asking the program to close

Not sure if I got a tick or a nine





I feel quite defeated at this point.






Can you name any other signals?


no







Can you tell me about the runlevels


Not a whole lot I know there was for halt.(I do know more about the runlevels but at this point my brain was on a tactical retreat, and if the doors didn't have retinal scanners I would have run from the building like a little girl....ok ok the retinal scanners were only to get into the room, it was the social contract that kept me there.)

tick





Another black out.






What is cross site scripting?


I was defeated, I was non caring. I answered with the enthusiasm of a mental patient on so much thorazine, his drool would drool.


I don't know, javascript, steal cookies something.




It seemed that seeing my interested fade, had somewhat diminished the perverse pleasure he may have been taking in the interview. The questions got a little stranger.

What's the farthest you could get in a MySQL injection attack?


I start pontificating on UNIONS and LIKE's and REGEXP's and he knew he had me back in the game.


No tick or nod, I don't think this was on his questions sheet





Do you know what ARP poisoning is?

Boy Howdy, I answered this with aces, explaining the arp protocol, and what programs to use to do this. How to do this on linux, windows, or how to write something in perl that would accomplish the task. Then I told him how you could even fake an ssl cert.


This peaked his interest. He said "But wouldn't there be a nag screen saying the cert wasn't valid. Certainly I wouldn't log into my bank if such a screen popped up"

"Neither would I, but would she" I pointed to the secretary that was several glass walls between us.


NOD.




He started a network question: If I had a subnet mask of 240...

Before he finished I said "16 hosts, 16 networks"


Nod


We talked about VLSM for several minutes


We got into an argument about UDP, I had this half thought out theory about offloading the handshake to the processor to conserve bandwidth(yes I realize I was wrong now, and did admit it in the interview). It was terrible, I argued with an interviewer with a half baked theory.


He congratulated me on knowing a lot about networking anyway, and said a lot of linux admins were weak in that area.






Name three ways to restart a linux box?

Again I had lost interest. "Umm, shutdown -r now, and probably one of the runlevels"

I can tell you started using linux a long time ago, most newer guys don't know shutdown -r.

This was his final and what I considered second compliment.





He asked me if I had any questions. I said I felt dumb. He said "Sometimes an interview is just to let you know, you aren't qualified for the job."




What am I doing about?



Well I purchased Linux Kernal in A Nutshell for the kindle app on my android and I've been reading it. I'm going to try and complete a http://www.linuxfromscratch.org/ tutorial this weekend. I have bookmarked a webpage that is the equivelent of man page for linux signals, and the wiki page for run levels of linux. I took this interview because my contract was running out on a web programming job(perl, but in a windows enviroment). I'm also going to get more organized and focused on what I need to be learning.



I'm also not going through recruiters unless I must. Unless it's this guy, The Antipimp , he's a friend and trustworthy. I've since learned my current recruiter(not the one that set me up on my interview/lied on my resume), is making around .7 what I make on every hour. So for the sake of arguement and easy math(ie these numbers are false), if I'm making 30 dollars every hour, my recruiter is making 18 every hour.*




So that's where I'm at. If you have suggestions on what to learn/read/do, please let me know.



* I just redid the math and it's actually closer to .8.

Tuesday, March 29, 2011

The Linux Job Interview from hell.

*I've been an (very) amateur linux enthusiast since 1999 and a profesional linux admin for 5+ years*


**Hi Redditors and Hacker News people, I got a huge amount of comments on specifics about the interview, like what the questions were, etc, I have since written that information here http://bsdpunk.blogspot.com/2011/03/questions-and-aftermath.html . **

So what do you do, when you've been bested? When you have been so wholly destroyed in an interview, it shakes you to your core. When you get about thirty percent of the questions right, and you can't blame anyone but yourself. It was a face to face interview, and when the interviewer saw you struggle, and you were on the right track he helped, in the capacity he could without giving you an answer.


A two hour face to face interview with only technical questions. No way to ease out of this one, no excuse. "The multiple choices was obscure", "The wording was wrong", "When would I ever need to know that." All those justifications were thrown out the window. It was no use to hold on my pride.
I had my skin ripped off me. I thought I was somebody, I thought I new Linux like the back of my hand. But more importantly I recognized, for the first time in the long time, that I knew very little. I'd like to blame the product of my environment. That for the past 6 or so months, I've had no coworkers, or friends in the field, to truly talk to, or compare notes. Only the occasionally tweet exchange with strangers. Or that I've been working in a windows environment for about the same amount of time. But this isn't the fault, this isn't why, it was my arrogance.

I've always done well in interviews, all types of interviews, but when it comes to tech interviews, they've always been like candy from a baby. Not this one. So I am going to lay some things down for you.


What did I do wrong? To start with, which is only the beginning. I didn't review the basics, you know stuff you learned in school, or just dicking around with Linux. So simple questions about the kernel boot process, stuff I hadn't though about in a while, because I was used to just booting machines in the cloud and setting them up with automated scripts I wrote, hadn't thought about the boot process in a while. Stuff like runlevels and signals, I know what they are, I know how to Google them, but I don't have exact memories, I know kill -9 is force and normal kill and ctrl-d are ask the program to quit....can I explain it more technical than that, apparently not.


I missed questions I knew but forgot the answers to, like the difference between asymmetric and symmetric encryption. I just forgot the terminology, cause I didn't even glance at a book; I had this thing in the bag I thought. If he would have asked me to describe PKI, I would have pwned that question like Charlie Miller, chowns a mac. But he didn't, I was lost.


I missed questions I didn't know the answers to, and had thought were irrelevant....until he explained the answers to me.
I even asked him to ask me questions on things I thought I knew, like rsync, and was humiliated worse than Ben Stiller in any of his movies. After being grilled on why I would use the v, I knew it was over.


After all this frustration, I had the audacity to get in an argument about UDP which I hadn't fully thought out, and of course my argument was crushed, and ultimately wrong to begin with. (I assure you at this point I had already crashed and burned so hard this was not a deciding factor in me being hired).


Did I go in with the wrong attitude? No, I don't think so. I just wasn't technically skilled enough for the position, I had a belief that, I can survive in any position as long as I'm given enough lee way for a couple of weeks so that didn't scare me off.


I'm going to say 99% of the failure of this interview was my fault, I wasn't skilled enough, and I didn't prepare, as I should. I would like to fault someone else for the other 1%, a recruiter who buffed my resume without my knowledge, sending me in the dragons den with embellished, if not downright false information, with my resume.... rewritten to serve his needs.






I'll follow this up with how I am going to remedy my skillset/interview/recruiter policy in the next few days.


EDIT: Ctrl-D is actually end of file, thanks to the peeps at hacker news. Please keep reporting inaccuracies and I will fix them as they are found.

Wednesday, March 9, 2011

Favorite way to regex a file using perl

Sometimes you want to do some magic fu on your file, while it's not loaded in a vim buffer. This is what I use with perl. I know there is probably a way to do this with sed, but I couldn't find it quickly enough. Most of the time when I do a search and replace out side of vim I want to replace something that's already in the file, with itself in a different position. For example:

I want to replace variablewordspace with variablewordtime, so in the file var.txt I have:

variablewordspace
hammerspace

So what I would do is:


cat var.txt | perl -pe 's/(\w+)space/\1time/'

which would give me the output:


variablewordtime
hammertime



For a brief description:
You are display the file var.txt, through the cat command. Then using the pipe (|) you are passing that to perl, with the switches p and e. Switch e allows you to run from the command line without explicitly writing a perl program, while switch p allows you to run a program against every line on standard input, and prints whatever is in $_ after each line. A search and replace using s/// with the search term in the first set of slashes

/(\w+)space/

The parentheses mark that as a group.

The \w+ means any number of word characters, as where the 'space' just represents the word space.

In the last set of slashes is what you want to replace it with.

/\1time/

\1 represents what is in that first set of parenthesis.

And time of course, represents the letters 'time'

Thursday, January 13, 2011

Simple Stupid Linux Tricks ssh port forwarding

At work I'm firewalled in, and I'm on a linux server...however they allow traffic over port 22. So it's really easy to get to meebo. You can do this with most sites, however if they require more than one port you'll need a more complex solution.

I fire up cygwin and type this in.(You can use any ssh client though)


ssh -L 8888:meebo.com:80 root@wereboobs.com -N

ssh creates a tunnel from me to wereboobs, which the proxy doesn't care about to meebo which the proxy does(ironic, no?). So now if I type localhost:8888 into my browser I can get to meebo without going through the web proxy. Bonus...the web traffic from meebo is encrypted until it reaches wereboobs.

Thursday, December 16, 2010

Grab your delicious bookmarks before they're gone

Rumors that delicious is being closed by yahoo, made me want to grab my bookmarks, Someone posted this on twitter

curl https://user:pass@api.del.icio.us/v1/posts/all


via :adactio

Which is nice but gives you all that xml gunk.

This gives you a nice list in a file bookmarks.txt

curl https://user:pass@api.del.icio.us/v1/posts/all | grep -E -oh 'http:\/\/.*?/"' | grep -E -oh 'http.*?/' > bookmarks.txt

Tuesday, December 14, 2010

Pull the alt / title tag from xkcd picture from command line

How to pull the alt (actually the title tag), from xkcd with the command line

[root@queerlikerice ~]# curl xkcd.com | grep -E -oh 'title=".* alt=' | grep 'title' | grep -E -oh '".*?"'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8375 100 8375 0 0 137k 0 --:--:-- --:--:-- --:--:-- 538k
"And if you labeled your axes, I could tell you exactly how MUCH better."



Bash cli:
curl xkcd.com | grep -E -oh 'title=".* alt=' | grep 'title' | grep -E -oh '".*?"'

Monday, November 8, 2010

Mounting a blue ray iso on linux, to play in vlc

Recently downloaded a blu ray movie on my seed box, went to play it and I could mount it in ubuntu but the default setting still would not let me watch the movie in vlc. However after a quick google search I went here:
http://ubuntuforums.org/showthread.php?t=1209981

And sure enough the guys advice which was to mount with:
sudo mount -o loop -t udf pathtobluray.iso /media/cdrom

Worked perfectly. Once mounted navigate to the directory with vlc /dev/cdrom/BDVM/STREAM/*.m2ts

I put an asterisk because I am not certain the m2ts is the same name on every blu ray.

Using perl to create hash tables like your mysql tables

The subroutine Below will take an array of table names and put the columns in a hash, then grab rows and match said rows with said field/column. So that $tableData('salesdatafirst_name') would be the value for the first name column in the tables sales data, in the row based on your condition in the second query of the subroutine.


sub get_table_data {
foreach(@_){
my @ColumnNames;
$data_name = $_;
$dbh = DBI->connect($connectionInfo,$userid,$passwd) or print "Couldn't connect to database: ". DBI->errstr;
$sql = "SHOW COLUMNS FROM $data_name";
$str = $dbh->prepare($sql) or print "Couldn't prepare query: ". DBI->errstr;
$str->execute() or print "Couldn't execute query: ". DBI->errstr;
while (@querytwo = $str->fetchrow_array()) { #loop thru results
$tableData{$data_name.$querytwo[0]}='';
$tableHashHelper = $data_name.$querytwo[0];
push(@ColumnNames, $tableHashHelper);
}

$sql = "SELECT * FROM $data_name WHERE condition = '$yourcondition'";
$str = $dbh->prepare($sql) or print "Couldn't prepare query: ". DBI->errstr;
$str->execute() or print "Couldn't execute query: ". DBI->errstr;
while (@Q = $str->fetchrow_array()) { #loop thru results
for ($i=0; $i<=$#Q; $i++) {
$tableData{$ColumnNames[$i]} = $Q[$i];
}
}
undef(@tableColumnNames);
$dbh->disconnect();
}

Saturday, November 6, 2010

Retrieving Exif data, or Where she at bro?




Geolocation data in some cameras and many smart phones is embedded in the photos that these devices take.


View Larger Map


**Technical information**

The incredibly simple script **must install Image::ExifTool**
Image::ExifTool can be installed rather easily, through cpan.

use Image::ExifTool qw(:Public);
my $info = ImageInfo("$ARGV[0]");

foreach (keys %$info) {
print "$_ => $$info{$_}\n";
}

run it like this:
perl meta.pl test3.jpg

Output for this looks like:

GPSLatitude (1) => 43 deg 49' 42.60"
GPSLatitude => 43 deg 49' 42.60" N
GPSLongitudeRef => West
GPSTimeStamp => 01:00:12.48
GPSLatitudeRef => North
GPSLongitude => 79 deg 7' 24.00" W
GPSPosition => 43 deg 49' 42.60" N, 79 deg 7' 24.00" W
GPSLongitude (1) => 79 deg 7' 24.00"
lane@skullfuckerthemagnificent:~/Pictures$ perl meta.pl test27.jpg
XResolution (1) => 1
ImageWidth => 600
Model => iPhone
ExifImageHeight => 1600
GPSLatitude (1) => 43 deg 49' 42.60"
ResolutionUnit => inches
ColorComponents => 3
BitsPerSample => 8
GPSLatitude => 43 deg 49' 42.60" N
MIMEType => image/jpeg
FileType => JPEG
GPSLongitudeRef => West
ResolutionUnit (1) => None
ExifToolVersion => 8.25
FilePermissions => rw-r--r--
JFIFVersion => 1.02
Directory => .
FileName => test27.jpg
ImageHeight => 800
XResolution => 72
Make => Apple
DateTimeOriginal => 2009:04:08 01:00:13
GPSTimeStamp => 01:00:12.48
CreateDate => 2009:04:08 01:00:13
YCbCrSubSampling => YCbCr4:4:0 (1 2)
ExifByteOrder => Little-endian (Intel, II)
FileModifyDate => 2010:10:22 07:43:26-05:00
ExifImageWidth => 1200
ColorSpace => sRGB
EncodingProcess => Baseline DCT, Huffman coding
FileSize => 58 kB
YResolution => 72
Aperture => 2.8
GPSLatitudeRef => North
GPSLongitude => 79 deg 7' 24.00" W
GPSPosition => 43 deg 49' 42.60" N, 79 deg 7' 24.00" W
YResolution (1) => 1
FNumber => 2.8
ModifyDate => 2009:04:08 01:00:13
GPSLongitude (1) => 79 deg 7' 24.00"
ImageSize => 600x80

and if you have linux, mac, or your operating from within cygwin on windows this helps:

perl meta.pl test3.jpg | grep 'GPS'

Output for this will look like:

GPSLatitude (1) => 43 deg 49' 42.60"
GPSLatitude => 43 deg 49' 42.60" N
GPSLongitudeRef => West
GPSTimeStamp => 01:00:12.48
GPSLatitudeRef => North
GPSLongitude => 79 deg 7' 24.00" W
GPSPosition => 43 deg 49' 42.60" N, 79 deg 7' 24.00" W
GPSLongitude (1) => 79 deg 7' 24.00"


GPSPosition is the one your looking for you will need to trim it for google maps(IE 43 49' 42.60" N, 79 7' 24.00" W).


Most photos that get uploaded to the intarwebs get altered by resizing software or watermarking software or what not. When these photos are altered, many times thier EXIF information is cleared and replaced with information about the software that has done this(ie imagemagic GD). So most photos are not very useful. Sites that might be useful are probably twitter related image storage sites, simply because they consider stuff like geotags valuable.

Using DBI putting field / column names in a hash table

use DBI;
use DBD::mysql;
use strict;
use warnings;

my $database = "ci";
my $host = "localhost";
my $port = "3306";
my $tablename = "happy";
my $user = "root";
my $pw = "wouldntyouliketoknow";

my $dsn = "dbi:mysql:$database:localhost:3306";
my $connect = DBI->connect($dsn, $user, $pw);

my $query = "SHOW COLUMNS FROM $tablename";
my $sth = $connect->prepare($query);
$sth->execute();
my %hash;
my @ary;
while(@ary = $sth->fetchrow_array){
$hash{$ary[0]}= '';
}
my $key;
my $value;

print "\n";
while (($key, $value) = each(%hash)){
print $key.", ".$value."\n";
}

Same as the perl script before, but using DBI module instead of Mysql Module.

Loading a hash with the field names from a mysql table using cpan's Mysql;

#!/usr/bin/perl

use Mysql;
use Data::Dumper;

$host = "localhost";
$database = "ci";
$user = "root";
$pw = "wouldntyouliketoknow";
$table = "happy";

$db = Mysql->connect($host, $database, $user, $pw);
$fields = $db->listfields($table);
@hammer = $fields->name;
%hash = map { $_ => 1 } @hammer;





So you can load up a has with the field names on one side, so you can have variables like $hammer{primary_id}.

Cygwin, Where's My hardrive?!? interrobang

/cygdrive/~driveletter~

This is more a note for me, lol. New Job has windows computers, yuck.