Archive for the 'Uncategorized' Category

Reset the Autoincrement column in MSSQL

Wednesday, July 24th, 2019

To reset the identity column in MSSQL use the following:

DBCC CHECKIDENT (tablename, RESEED, 0)

Just replace tablename with the table, and change the 0 to the number minus 1 that you want to have as the next row.

For example, entering 0 (zero) will give the next row identity of 1.

Tags:

Vagrant: editing metadata_url file causes illegal character issue

Tuesday, October 10th, 2017

I was editing the ~/.vagrant.d/boxes//metadata_url file in a box I was testing and when I ran “vagrant box update” I received the following:

$ vagrant box update
==> default: Checking for updates to 'edev-developer'
    default: Latest installed version: 2.0.5
    default: Version constraints: 
    default: Provider: virtualbox
There was an error while downloading the metadata for this box.
The error message is shown below:

Illegal characters found in URL


The illegal character happens to be an EOL char added automatically by your editor, mine was vi, and that is causing the error. I used the following commands to remove the eol character from the file.

perl -pe 'chomp if eof' .vagrant.d/boxes//metadata_url > .vagrant.d/boxes//metadata_url2
mv ~/.vagrant.d/boxes//metadata_url2 ~/.vagrant.d/boxes//metadata_url

Chrome clear DNS cache

Monday, September 25th, 2017

I regularly have to test internal systems by adding an entry to the hosts file on my computer. As I keep quite a few tabs open this can cause issues when I need to use the original host system to do some work as I do not want to close all of my tabs to restart Chrome. And when I finish my testing and remove the entry from the hosts file, I need to restart the browser to make sure that I do not have the test DNS entry for my host.

IF you place the following in the address bar:

chrome://net-internals/#dns

You will get a page for DNS that has the following button:
Clear host cache button

This will clear the browser DNS cache and you can use the list below to see the current state of DNS entries below to verify your DNS is as expected.

How to exit Vi(m)

Monday, June 12th, 2017

So you have found yourself in vi or vim and are unable to exit. The following options are available.

First you need to get to command mode, so either hit or Ctrl-c will switch to command mode from insert mode.
Then use the following:
Exit if there are no changes to the current buffer without writing

:q

Exit even though there are changes to the buffer without writing

:q!

Write and exit ( those are capital Zs)

ZZ

Exit and do not write

ZQ

Sprite Starter Tutorial

Saturday, April 15th, 2017

There are times that you are going to want to add some imagery to your site. This would normally mean using many different image files which will increase the load time for your site. What if you could use a single image and display portions of that image throughout your site.

You could use use a single image called a sprite sheet. This single image file can hold many different images in different tiles for use through out your website. This allows you to load a single file to your page and adjust the viewport in different locations throughtout your site to display the images or icons you are using. Many major websites use this technique.

Let’s use an image like the following:
smiley_sad

The size of this image is 220px x 110px. Each tile of the grid is then a 110px x 110px image. So we need to allow for a viewport to this image that is the size of the tile.

The method we are going to use is a simple div element with the class of “sprite”.

<div class="sprite >
</div>

The CSS for this element will use height and width to define the size of the div. You could also create a placeholder image of the size you want your image to be that is a transparent png and place that inside the div, but that is not necessary.

This snippet is the CSS that we require to show the first image with the smiley face in the div. We specify a height and width for the div to create a viewport into a segment of the image. Next set the background of the div to the image url. The last step is to make sure that the image does not repeat.

.sprite {
width: 110px;
height: 110px;
background: url("http://etechtips.com/wp-content/uploads/2017/04/smiley_sad.png");
background-repeat: no-repeat;
}

In order to display the next image in the sequence you need to use the position properties of the background property. Using the hover pseudo class will allow us to demonstrate the change image update. In the hover property we only need to override the background property with a position offset of -110px in the x direction. Notice that we have used a negative to move the image to the left. The origin of this image is considered 0,0.

.sprite:hover {
  background: url("http://etechtips.com/wp-content/uploads/2017/04/smiley_sad.png") -110px 0;
}

If you used a larger image with more tiles you could scale in both horizontal and vertical directions to show more images.

Example:

If the example doesn’t show in the article, either visit the single page post or checkout this codepen: Smiley Sample

Due to a minor adjustment, I used an offset of -109px for this image or I got a slight shift of the image when I hovered. You should only see the shift of smile to frown when you mouse over the image.

The tiles can be uniformly the same size or you could try packing in many images of different sizes and shapes. Just make sure that you allow for the viewport to not display overlapping images.

Tags: ,

Useful Git Aliases

Thursday, March 9th, 2017

When you use git often, it is helpful to implement some aliases for frequent commands. Git has config options to allow for shortening commands or allowing you to use a simple command instead of a line of text that is difficult to remember.

Some simple shortcuts:
To make checkout shorter

git config --global alias.co checkout

This will allow you to just type:

git co

To make status shorter:

 
git config --global alias.st status

This will let you see the log with branch indicators and a graph of the branches:

git config --global alias.mylog "log --pretty=format:'%h %s [%an]' --graph"

This is similar to the mylog alias but is useful on a color terminal as it will highlight useful items in the comments:

git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit ==all"

The results will be the following lines in your .gitconfig file:

[alias]
        st = status
        co = checkout
        mylog = log --pretty=format:'%h %s [%an]' --graph
        lol = log --graph --decorate --pretty=oneline --abbrev-commit --all

Tags:

OCR: Convert image to text

Thursday, February 26th, 2015

So I had a colleague receive a list of cities to import to a database in an excel spreadsheet. It turned out that someone had placed an image of the data in the spreadsheet instead of the text. This was looking to be a long day of typing when I happened upon the following awesome site: Online OCR . I was able to convert the image to text in MS Word, MS Excel or plain text.

All you have to do is take the image and use Paint or any image software, copy it from the document and save it as a png or jpeg. Then Save the file and you have the text ready to go. I did have a few mis-recognized letters, but changing a few keystrokes was better than the hour I would have wasted typing out all the cities.

And all this without registration. When I registered it gave a few more options for output such as PDF, different versions of Excel and Word, and RTF. Also multi page support, convert to black and white and creating zips.

There is also multi-language support and even an email service to send in the your docs and receive an email with the converted doc. There is a limit to the amount of pages you are allowed with the login service and you can purchase sets of pages in chunks if you use the service regularly.

Great Service and I was able to convert the list in just a few minutes.

Thanks Online OCR!

Windows GodMode folder

Monday, January 12th, 2015

I just found a way to create a settings folder in Windows 7. This God Mode folder can be created by:

1) Create a new Folder
2) Rename the folder to : GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

Then the folder will change its icon and give you access to the settings for your computer in one place.

Postgres: Create table if it doesn’t already exist

Friday, October 24th, 2014

I have a script that uploads a series of data into tables and occasionally I have an alternate table that is not part of my company template so I need to create the table at run time.  I do not want try to create the table if it exists already.  I also did not want to have to write a table check query and run that separately each time.

I looked into creating a function to do this but I found that with the release of Postgres 9.1 there was an addition of the “if exists” or in my case, “if not exists” that allowed me to run one query that would only create the table if the table does not exist already.

CREATE TABLE IF NOT EXISTS {schema}.{table_name}

(

sku character varying(100) not null,

product_image character_varying(300) not null

);

Invalid JPEG when uploading to photo service

Wednesday, April 23rd, 2014

I create cards in Adobe Illustrator or Photoshop on occasion and have had issues with getting my prints made at on-line or in-store photo services (such as Walgreens, Walmart or Target). I have received invalid JPEG errors.

You will need to make sure that your color mode is set to RGB for your files and not CMYK.

Ironically, even though most printers do better with CMYK, the RGB format is required for your JPEGS at these services.