Time tracking blog

 
  • All
  • |
  • CEO
  • |
  • Fun
  • |
  • Geeks Behind TSheets
  • |
  • Marketing
  • |
  • News
  • |
  • Products & Features

Archive for the ‘Tips & Tricks’ Category

27
Jan

 

Here’s a cool tip for all our Mac users out there: Run TSheets as a desktop app.  This allows for easier and quicker time tracking access.

Here’s how it’s done:

  1. Download and install Fluid
  2. Launch Fluid and create a site specific browser with the settings pictured below (you’ll want to point this to your TSheets account URL, or you can use https://app.tsheets.com/ip/)
  3. If you’ve done everything right, you’ll get a success message.  Click ‘Launch Now’
  4. From here you have two options. 1) run as a desktop app from the dock or 2) run as an app from your toolbar.  If you choose option 1, you’re finished.  For option 2, keep reading…
  5. From the toolbar of the app you just launched, select the main app menu item and choose ‘Convert to MenuExtra SSB’
  6. Click ‘OK’ to continue
  7. You’ll now see the app shows up in your toolbar (along the top, close to your clock)

Hopefully you’ll find this as useful as I do (I use it more often than our main web application).

Let us know what you think.

A little while back, I wrote this article that explained some awk magic for extracting the restore information for a single table from a mysqldump file.  Since then I’ve created a Perl script that accomplishes the same thing, but is a little more flexible.  The Perl script is available for download here.  I’ve tested it on Linux, but it should work from Windows as well if you have Perl installed. So now you have three options when needing to get one table out of your mysqldump file.

Method 1: Perl script

This script will parse a full mysqldump file and extract the necessary portions required to restore a single table.  The output is printed to STDOUT, so you’ll want to redirect to a file from the command line, like so: extract_sql.pl > somefile.sql

Usage Summary (run the script with no parameters and you’ll see this):


Usage:  extract_sql.pl -t <table name> -r <restore file> [options]

Required:
-t <table name>       table name to extract from the file

Optional:
-r <restore file>     mysqldump file that you want to parse. Uses STDIN if
nothing is specified
--listTables          If set, then a list of tables existing in
your restore file is returned,
and no other actions are taken
--noExtras            If set, then extra cmds at top of mysqldump file
will not be included (such as disabling foreign key checks).
Usually you will want these things changed before restoring a
table, so the default is for these to be included.
-v                   verbosity - use multiple times for greater effect
-h                   Display this help message

So, to extract the info needed to restore table ‘mytable’ from the mysqldump file ‘mydumpfile’, you’d run:

extract_sql.pl -t mytable -r mydumpfile > mytable.sql

or, if your dump file is gzipped, you could save a little time and space by doing:
cat mydumpfile.gz | gunzip | extract_sql.pl -t mytable > mytable.sql

To see what table names are within your mysqldump file, run:

extract_sql.pl –listTables -r mydumpfile

The script has a lot of extra functions, etc. in it for logging and cmd-line parsing, but the meat of what it does is here (NOTE! This is not the entire script, just an excerpt of it, use the download link near the beginning of this file to obtain the entire script to use it yourself):


if ($conf{'restoreFile'}) {
## open the mysqldump file
open(STDIN, "< $conf{'restoreFile'}") || quit("ERROR => Couldn't open file $conf{'restoreFile'}: $!", 3);
}

my $flag = 0;

## go through the file one line at a time
while (my $line = <stdin>) {

if ($conf{'listTables'}) {
if ($line =~ /^-- Table structure for table `(.*)`/) {
print $1 . "\n";
}
}
else {

## if we're not ignoring extra lines, and we haven't set the flag, and if it's not a 40000 code, then print
if (!$conf{'noExtras'} &amp;amp;&amp;amp; !$flag) {
if ($line =~ /^\/\*!(.....).*\*\//) { print $line unless ($1 == 40000); }
}

## set a flag when we encounter the table we want
if ($line =~ /^-- Table structure for table `$conf{'tableName'}`/) {
$flag = 1;
printmsg("Turning flag on", 1);
}
## turn flag off as soon as we encounter next table definition
elsif ($line =~ /^-- Table structure for table/) {
$flag = 0;
printmsg("Turning flag off", 1);
}

## if flag is set, then print to STDOUT, otherwise just move on
if ($flag) {
print $line;
}
}
}

Method 2: awk

First, you have to know where in your mysqldump output you want to begin your extraction, and where you want to end it. The key here is finding something unique at the beginning and ending of the block that won’t be found anywhere else.

A sample mysqldump contains something like the following:


--
-- Table structure for table `test1`
--
...
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test1` ( ...
LOCK TABLES `test1` WRITE;
INSERT INTO `test1` VALUES (1,0,’2 ...
UNLOCK TABLES;
...
–-
–- Table structure for table `test2`
–-

As you can see, we have a line with the comment “Table structure for table `test1`”, then all of the dropping, creating, and inserting for the table, and then another comment for the next table. These two lines are perfect for grabbing all of the operations pertinent to our one table.

To extract the dump for a single table from an entire database dump, run the following from a command prompt:

$ awk ‘/Table structure for table .test1./,/Table structure for table .test2./{print}’ mydumpfile.sql > /tmp/extracted_table.sql

The above command searches through the dump file, and as soon as it matches a line containing the first search string (denoted by the first set of slashes), it prints that line and every subsequent line until it encounters a line containing the second search string (denoted by the second set of slashes). FYI, the periods surrounding the table names above are wildcard characters.

Now the extracted_table.sql file contains the SQL to restore your table. One final thing: There are usually various parameters at the top of your mysqldump file that you may need to set before restoring your table, depending on the complexity of your database (i.e. disabling foreign key checks.)

To restore your table, you’d run:

$ mysql -u user -ppassword mydb < /tmp/extracted_table.sql

Voila! – you’re back in business.

Method 3: Restore elsewhere and extract

Another option is to restore your data into a temporary database (assuming you have the disk space), extract the table you’re interested in to it’s own dump file, and then restore that dump file to your original database.

Create a new database, name it something easy to distinguish from your production one, i.e. fakedb.

Restore your data to the fakedb with a command like this:

$ mysql -u user -ppassword fakedb < mydumpfile.sql

From fakedb, grab the data you want from your target table:

mysql> select * from targettable into outfile “/tmp/mytablebackup.bak”;

On the production db, where you have your undesired data, clear it all out with:

mysql> delete from baddatatable;

Import the good stuff back into it:

mysql> load data infile “/tmp/mytablebackup.bak” into table baddatatable;

Now you can rinse and repeat if you want to keep trying whatever your initial operation was until you perfect it. Make your changes, delete everything, load it back in, redeux.

Hope this is useful.

It’s late July.  The 4th has come and gone, and we’re starting to see autumnal items make their way onto the store shelves.  The kids have got another month or so to go before they’re back at the books.  Looking forward to, or have you already taken that week by the lake this summer?

Barack Obama has got his vacation on his mind as well.  That and then some.  I’d love to tell you that I got a few moments with Mr. Obama earlier this week, but unfortunately he was busy meeting with David Cameron, the Tory Party leader in the UK.  What I DID have time for this week was to catch an excellent article in the New York Times about Mr. Obama’s and Cameron’s ‘hey is this thing on?’ quasi-open mic conversation they had last week:

Mr. Cameron: You should be on the beach. You need a break. Well, you need to be able to keep your head together.

Mr. Obama: You’ve got to refresh yourself.

Mr. Cameron: Do you have a break at all?

Mr. Obama: I have not. I am going to take a week in August. But I agree with you that somebody, somebody who had worked in the White House who — not Clinton himself, but somebody who had been close to the process — said that should we be successful, that actually the most important thing you need to do is to have big chunks of time during the day when all you’re doing is thinking. And the biggest mistake that a lot of these folks make is just feeling as if you have to be …

Mr. Cameron: These guys just chalk your diary up.

Mr. Obama: Right. … In 15 minute increments and …

Mr. Cameron: We call it the dentist waiting room. You have to scrap that because you’ve got to have time.

Mr. Obama: And, well, and you start making mistakes or you lose the big picture. Or you lose a sense of, I think you lose a feel …

Mr. Cameron: Your feeling. And that is exactly what politics is all about. The judgment you bring to make decisions.

Mr. Obama: That’s exactly right. And the truth is that we’ve got a bunch of smart people, I think, who know 10 times more than we do about the specifics of the topics. And so if what you’re trying to do is micromanage and solve everything then you end up being a dilettante, but you have to have enough knowledge to make good judgments about the choices that are presented to you.

Whether you’re planning on support Barack or John this November, you’ve got to give Obama some credit here.  He’s taking advice from some very smart people.  These people have advised him to take time to think.

Obama may be running for president, you may be running a small business, but at the end of the day, both of you are striving for the same goal: To steer the ship on the right path, avoid the icebergs, keep the crew happy, and try to leave her in a better condition for the next captain.

Using TSheets as a time tracking tool for your employees is one way to cut down on costs, but it’s also a great way for you, as the business owner to organize and review your own time management.

Do it like Barack.

If senior White House advisers, close to both Clinton and Obama advise scheduling time to think, shouldn’t you be doing the same?

Zemanta Pixie

NOTE: A newer article has been written detailing some additional methods for doing this. Read it here

Warning: the content which is to follow contains a lot of acronyms and jargon that is only meant for the technically strong and the very computer-literate. If you do not speak ‘command-line’ and don’t understand the meaning of words such as ‘mysql’ or ‘linux’ or ‘awk’, then my condolences – and you can just skip along to the other fare on our blog. You might enjoy the 38 seconds post or seeing a cougar grabbing a Bull Elk by the jugular.

I thought it was high time that we provide some material that would aid and assist our fellow system admins on the ‘net. When you’re going through the daily grind of taming all of those ones and zeros that just want to be free – anything that can save you a little bit of time and frustration is always welcome.

Someday you may find yourself in a situation where you want to restore a single table of your MySQL database. Hopefully this is in a lab situation or on a personal development box somewhere – but even if it is production you need not fear. There are plenty of articles about restoring your entire database, but not a lot about restoring a single table. What if your coding compadre’s mistakenly change the field for every row in a table on you, or maybe you want to alter all of the data in a table but want an easy way to ‘reset’ things so that you can tweak and try again? If you aren’t taking table level backups restoring that single table can be rather difficult. You’ll locate your MySQL dump, and realize that it is huge (even when zipped), and you don’t want to wait around to restore your entire DB in order to recover one measly table. So what to do? The file is too large to open in a text editor and do anything meaningful with it – it would take way too much time. This is where a little bit of ‘awk‘ magic can save your day. Using awk, you can extract a block of text from the MySQL dump that pertains to the table you want to work with.

First, you have to know where in your mysqldump output you want to begin your extraction, and where you want to end it. The key here is finding something unique at the beginning and ending of the block that won’t be found anywhere else.

A sample mysqldump contains something like the following:

--
-- Table structure for table `test1`
--
. . .
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test1` ( . . .
LOCK TABLES `test1` WRITE;
INSERT INTO `test1` VALUES (1,0,'2 . . .
UNLOCK TABLES;
. . .
--
-- Table structure for table `test2`
--

As you can see, we have a line with the comment “Table structure for table `test1`”, then all of the dropping, creating, and inserting for the table, and then another comment for the next table. These two lines are perfect for grabbing all of the operations pertinent to our one table.

To extract the dump for a single table from an entire database dump, run the following from a command prompt:

$ awk ‘/Table structure for table .test1./,/Table structure for table .test2./{print}’ mydumpfile.sql > /tmp/extracted_table.sql

The awk command is very powerful – the above command searches through the dump file, and as soon as it matches a line containing the first search string (denoted by the first set of slashes), it prints that line and every subsequent line until it encounters a line containing the second search string (denoted by the second set of slashes).  FYI, the periods surrounding the table names above are wildcard characters.

Now the extracted_table.sql file contains the SQL to restore your table! One final thing: There are usually various parameters at the top of your mysqldump file that you may need to set before restoring your table, depending on the complexity of your database (i.e. disabling foreign key checks.)

To restore your table, you’d run:

$ mysql -u user -ppassword mydb < /tmp/extracted_table.sql

Voila! – you’re back in business.

Alternate Method

A second option is to restore your data into a temporary database (assuming you have the disk space), extract the table you’re interested in to it’s own dump file, and then restore that dump file to your original database.

Create a new database, name it something easy to distinguish from your production one, i.e. fakedb.

Restore your data to the fakedb with a command like this:

$ mysql -u user -ppassword fakedb < mydumpfile.sql

From fakedb, grab the data you want from your target table:

mysql> select * from targettable into outfile “/tmp/mytablebackup.bak”;

On the production db, where you have your undesired data, clear it all out with:

mysql> delete from baddatatable;

Import the good stuff back into it:

mysql> load data infile “/tmp/mytablebackup.bak” into table baddatatable;

Now you can rinse and repeat if you want to keep trying whatever your initial operation was until you perfect it. Make your changes, delete everything, load it back in, redeux.

Hope this is useful.

We all know that TSheets is excellent at tracking time for businesses and professionals alike, but it’s also great at tracking time for non-business related activities. For example, you can easily adapt TSheets to function as a workout/exercise log.

Here’s how to use TSheets to track your workouts:

  • Sign up for a free single user account.
  • Setup job codes to function as “Activity Codes.”  Some examples include: running, lifting weights, stretching, hiking, cycling, skiing, etc.
  • Track your workout time proactively or retroactively.  Huh?
    • Proactively: Clock in with your TSheets account using your activity code before you start your workout, then clock out when you’re finished. This is easily accomplished with your mobile phone using our mobile version, or if you’re using an IPhone, our IPhone version.
    • Retroactively: Perform your workout, then afterward use the Time Slider to record your workout.
  • Use the notes feature to record any workout specifics.  Such as: weather conditions, mileage, heart rate, calories burned, how you felt, etc.
  • Run reports to summarize your workout time, broken down into activity codes.
Workout Report Sample

Why should you track your workout time?  Accountability.  By recording your workout time, you’re creating accountability to yourself.  This is a huge step in helping you reach and achieve your goals.  Not to mention the excellent bragging rights you’ll have with your friends/family when you show them how many hours you worked out last week.

We like to think of TSheets as a simple and easy to use online timesheet.  However, we’re not so naive to think that all of our Customers are going to completely understanding all of the terminology that is used. Here is a top ten list of online timesheet definitions that you will see in TSheets.

  1. Administrator – A user with complete access to your entire TSheets account.
  2. Affiliate Program - A program that offers you a reward for recommending TSheets to other business owners and colleagues. Learn more.
  3. Authorization – Turning a computer or mobile device into a time clock, allowing your employees to log in/out of TSheets from designated PCs or mobile devices. Learn more.
  4. Employee – Any user that uses a username and password to log into TSheets will be found on your employee list, even Administrators are on this list even though they are not treated the same for authorization purposes. Learn more.
  5. Group – A collection of employees that you wish to sort, organize and track the time for. (Such as Marketing Department, Accounting, Boise Store, etc.) Learn more.
  6. Job Code - A name given to a task that allows you to track the amount of time employees spend on that task. Learn more.
  7. Manage – Adding, Editing and Deleting. (for example Managing Timesheets allows you to add, edit or delete timesheets)
  8. Permissions – Responsibilities that an Administrator can assign employees to give them access to specific TSheets functions. (for example an Administrator can assign a bookkeeper permission to view reports without giving them access to the entire TSheets account) Learn more.
  9. Time Card - The window that holds all of the tools necessary for your employees to clock in/out, select or switch job codes and add notes to a timesheet. Learn more.
  10. Timesheet – A representation of a period of time that is recorded between one clock in and clock out sequence. (for example one 8-5 shift with an hour lunch would record two timesheets, one from 8am-12pm and then another from 1pm-5pm)

To see more definitions or to add you own online timesheet definitions visit our TSheets Dictionary.

13
Mar

 

Inevitably we all come to a point with a product that we just can’t figure something out. And although TSheets is designed to be super simple and easy to use we aren’t naive enough to think that you will never need some help. That’s why we created our very own Wiki.

On our wiki you will be able to access the TSheets User Guide and Search through multiple pages of TSheets How To’s, Definitions, Videos, Screenshots, Screencasts and even the latest Active Features List. If you ever get stuck, the odds are that you will be able to find the answer on the wiki. And, if you find yourself knowing more about TSheets than our wiki does you can always add, edit and remove any information you’d like.

What is a Wiki? Here’s what Wikipedia says:

A wiki is software that allows users to easily create, edit, and link pages together. Wikis are often used to create collaborative websites and to power community websites. These wiki websites are often also referred to as wikis; for example, Wikipedia is one of the best known wikis.[1] Wikis are used in many businesses to provide affordable and effective Intranets and for Knowledge Management. Ward Cunningham, developer of the first wiki, WikiWikiWeb, originally described it as “the simplest online database that could possibly work”.[2]

Wiki Wiki (/wiːkiː wiːkiː/) is a reduplication of wiki, a Hawaiian word for “fast”. Some have suggested that wiki means, “What I Know Is.” However, this is a backronym.

The anonymous arm is back, explaining how your employees will interact with TSheets, and how our software changes any personal computer or web enabled mobile device into a time clock. More details about making our time and attendance software work for you.

Setting up TSheets is as easy as 1-2-3. Watch an anonymous arm explain how to get the TSheets time and attendance system working for you.