Adding OSX Automated Tasks for Git Commits

Suppose you work on a project where you are spending a lot of time focused on the code and fixing the bugs that keep popping up. It’s been a stressful day and you know it, the worst of it is when you forget to commit your changes you have been working on the whole day. Then keep on reading..

Now I’m proposing having an automated script which will run git status on your repo every night and checking if things need to be committed or not.

Here’s how you can do it:

Requirements:

  • OSX
  • Being comfortable writing shell scripts

1. Create an Automator

Now to create an automator for certain time, this is a bit different:

  1. Open Automator
  2. Choose Calendar
  3. Apple Script

For clearer way to create this automator, here’s a good video tutorial to create calendar automators for that.

on run {input, parameters}
	tell application "Terminal"
		if not (exists window 1) then reopen
		activate
		do script "gitcommit" in window 1
		delay 2
		close window 1
	end tell

	return input
end run

Now this automator is basically calling a gitcommit shell script which you on your machine.

2. Create Shell Script

Here’s what you do to create shell script:

  1. Open your favorite editor
  2. Write some code in it
  3. Close it, run chmod 700
  4. Copy and paste this very file in your usr/local/bin directory

Here’s the code for that shell script:

 

#!/bin/bash

open -a Terminal

cd path/to/osx_actions
source ready.cfg

if [[ $var1 == 'commit' ]]; then
	cd path/to/your_repo
	if git status | grep -q 'nothing to commit'; then
	  echo "already up to date"
	else
		echo "a commit needs to be done."
		git add -A
	 	git commit -m "$var2"
	fi
fi

Now, this bash script goes and read from a cfg (configuration file) you have. In this case, I have my configuration file under osx_actions directory.

3. Create Configuration file

The cfg file basically looks like this:

var1=commit
var2="your default commit message"
  • var1 is a flag whether to perform commit operations or not. It takes values [commit/nocommit]
  • var2 takes the default commit message you have, off course if commits happened automatically without you changing this message you may need to do git commit –amend to edit that message for that commit be more meaningful.

Now you are almost done.

Just go to your calendar, and using the same mentioned video above:

4. Add Event to Calendar

Add an event to your calendar, choose whether you want it to repeat and how frequent and also add the time on which you want to this script to run.

Hope this tutorial helps.

Happy Coding ūüôā

References Used

Advertisements

Livestyle

So, I think this is one of the coolest tools for one to us in creating / editing your styles right on the style.

Not only I have used it and found it really handy, but its convenience¬†comes now with its support for SASS, editing your scss and less files can’t be easier. Now after praising this tool, I have to point out something that kept me hanging for few days. It had an issue picking up global variable colors;

Example:

$p-color : #000;
$t-color : #ff7;

body {
background-color: $p-color;
}

These global colors weren’t picked up, which made me scratch my head a couple of times till I found that that syntax is not accepted. Having a space before the color breaks it.

The correction therefore is like:

$p-color: #000;
$t-color: #ff7;

 

My two cents tips for someone using livestyle, this amazing tool; livestyle

 

Accessing Your localhost from your mobile device

You have your localhost set up, and you are working on your responsive website, after trying many of the simulators. You still want to test on actual devices how the sites are going to look like.

Here’s a very simple way of testing your sites and viewing them on your mobile devices.

  1. Have both your localhost computer and your mobile device connected to the same wifi.
  2. Get the IP address of your localhost
  3. Get the port number for your localhost
    portnumber
  4. Write in the following address in your mobile browser: http://ipaddress:portnumber/webdirectory
    Example: http://192.168.0.100:8888/CSSTesting

Now you got it.

My New Chrome Extension – Tweet A Link

Tweet a Link Chrome Extension

Tweet a Link Chrome Extension

Just finished creating a new chrome extension which helps you tweet the urls you have one-click away. Rather than search for the Tweet button within pages, you have in your extensions in your browser.

No more you need to look for the tweet button or copy and paste the urls you like in order to tweet a certain page you like.

You can search it on the chrome store: “Tweet a link”

or you find it in the following link:

Enjoy your surf and sharing.

CSS – Safari ignoring width property

This has been occurring lately, and I couldn’t find much written about it, took me a couple of days googling it and trying to find what would be the reason that Safari would ignore our width property. After discovering that the width property is completely messed up on Safari browser only on Mac computers ¬†as Safari on Windows didn’t have the same. I found that the solution for that is just to add a max-width property along with the width property. This has fixed it for the most part. No much reasoning I found after that, but seemed to me that width property has be associated with a max-width property as well in order to have the layout looking right.


div {width: 155px; max-width: 155px;}

 

If anyone has different suggestions or a reasoning behind this, surely share.

Stockulator on your iDevice

Here’s an app I developed more than a year ago and has been on the app store for a year now with some under 1000 downloads without any advertisement.. word of mouth and usefulness of the app.

The App as described on the apps site:   Stockulator is a calculator designed for helping you estimate and calculate your possible gain vs. loss when a stock price rises or falls. It simulates your entire calculations of number of shares, amounts etc.. and helps you project how much money you are going to make before buying or selling any shares.

Get the app: http://itunes.com/apps/stockulator 

Help for using the app: http://apps.amplioslabs.com/stockulator/

Welcome to your ideas and comments.

Thanks,

Joe

UX Common Pitfalls – 3

3. Relying on Flash to Convey a Message

So after discussing two of the major pitfalls for UX designers these days, one has to discuss what seems to be a controversial topic among many of the UX designers these days; whether to use Flash in sites or not?

Yet the discussion here isn’t as much on discussing the pros and cons of using Adobe Flash, for this I’d recommend some of the well written articles about this:

Website Performance

No one can deny that Flash has added lots beautiful interactive design when it was first introduced yet later, we discovered the prominent issues evolving from building sites Flash. The Cons of using Flash are so much user based, as you may have noticed. First, it has performance issues for the site, this affects usability. Performance directly affects usability.¬†According to an article about website optimization, Amazon found out that every additional 100 milliseconds of load time decreased sales by 1 percent.¬†¬†In fact, user frustration increases when page load time goes more than 8 seconds. That same article presents a study by Google, that adding half a second to search results decreases traffic and revenues by 20 percent. –¬†The Psychology of Web Performance

Unfortunately, many of the UX experts these days are technically detached which makes them thinking of mainly having a fancy site. Having a fancy site does have its trade offs. ¬†And when that tade-off is a performance issue, you have fallen into one of the worst yet common pitfalls in UX design. UX experts, hence, have to study well that their fanciness could affect site’s speed. Site’s slow speed would frustrate the user’s experience. Frustrated user’s experiences would decrease traffic and you’re headed to a big failure. A good article about Designing for Performance is presented here on alistapart.com,¬†Improving UX Through Front-End Performance

Accessibility

Second major issue you’ll face with building sites in Flash it does not work well for accessibility, since it is based on¬†images and that has the hindrance of having alternative texts, again the issue with screen readers.

Touch Screen Devices

Third major issue would be its compatibility with touch screens, something you would not want to ignore or forget when building sites today. People browser through their iPads and Galaxies everyday and this number is increasing significantly as I mentioned before in my first blog of this series.

Flash Plugins

Last major point in using Flash is:

flashErr

I am sure many of us have seen these messages before. Yes, plugins do have their issues and they are not very stable. In using Flash into your site, you are setting yourself up to whatever issues the user may have with their browsers. And the most common of the issues on browsers are the Flash crashing issues.

 

Then here comes the question, when should one use Flash then?

When Not?

So before saying the when? I have to say the when not? As mentioned in the title of this blog, it should be used by you shouldn’t rely on it in conveying your message. especially if this message is warning, like ¬†weather site warning of thunderstorms, or utility site warning of power shortage, these messages should be in developed using Flash.

Another instance where you do not want to use flash is relying on it on user’s enrollment and payment, since this could pose issues as well like plugin crashed while user is enrolling or paying. You do not want your users to face such issues.

When to use Flash?

Flash can be of very good use if you are presenting some that best be presented graphically, such as car model sites, fashion sites, artists/musicians or cartoon sites. These are just few examples.

It can also be used within your normal site to present a certain ad which you think would best be presented in flash. Many of the major sites are practicing this and it still provides good experience for the use. Such as bbc.co.uk, USAToday and many others..

Flash can be used in many instances, but bear in mind, it should only be used when the site’s performance isn’t badly affected and goes along only when it is needed. For this reason, UX experts should study well how sites are made and optimized technically before coming up with too fancy ideas which would affect badly the user’s experience due to the mal performance of the fancy site.