Author: Sarfraz Khan

Redirect to different sites based on subdomains

Before I get to the meat of this post, you should know that when you want to simply redirect a site from http to https and you are using IIS, you can use one of two solutions:

  1. Add the following to the head:
    <meta http-equiv="refresh" content="0;URL='https://sarfraz.pro/'" />
  2. Use HTTP redirect in the site settings.

But what do you do if it is getting more complex that this, and you are presented with a scenario where:

    • http://sub1.example.com needs to go to https://sub1.example.com
    • http://sub2.example.com needs to go to https://sub2.example.com
    • http://example.com needs to go to http://www.example.com

With a little javascript, you can easily take care of this on the client side. Here is what you do.

Add the following to the head:

<script type="text/javascript">
function codeRedirect() {
if (window.location.hostname == "sub1.example.com" &&
window.location.pathname== "/" ) {
ref = 'https://sub1.example.com';
}
if (window.location.hostname =="sub2.example.com" &&
window.location.pathname== "/" ) {
ref = 'https://sub2.example.com';
}
else if (window.location.hostname =="example.com" &&
window.location.pathname== "/" ) {
ref = 'http://www.example.com';
}
window.location.href = ref;
}
</script>

Modify the body tag as such:

<body onload="codeRedirect()">

That’s it.

If you want to add more redirects into the function, just copy one of the “if” statements and paste them before “else if”. Then modify the hostname and ref with the new addresses. The hostname is what you want to direct from, and the ref is where you want to redirect to.

Filed under: JSTagged with: , ,

Modifying the height and width of CSS pseudo element content

If you want to add an image before or after an html element, you most often use the pseudo-elements :after and :before. For example, when you want to add an image before a link, you can write it like this:

a:before {
url(image.png);
}

But you can’t control the width or height of this image this way. If it is absolutely necessary for you to control the dimensions of this pseudo element, the following is what you do:

  1. Move the image to the background image property.
  2. Define the height and width of the pseudo element. These are the dimensions of the image.
  3. Make the content an empty string.
  4. Give the background-size the same dimensions as the image.

This is how you would do it in CSS:

a:before {
background-image: url(image.png);
background-size: 40px 40px;
display: inline-block;
width: 40px;
height: 40px;
content: "";
}

Filed under: CSS

CSS for DIVs as shadowed curved boxes in a line

CSS for the shadowed box. You don’t need anything beyond this to create a shadowed box. The rest just shows you how to line it all up.

.box {
-webkit-border-radius: 6px 6px 6px 6px;
border-radius: 6px 6px 6px 6px;
-webkit-box-shadow: 3px 3px 3px 3px #ABABAB;
box-shadow: 3px 3px 3px 3px #ABABAB;
resize: both;
overflow: auto;
min-width: 50px; /*suggest a min-width & min-height*/
min-height: 50px;
background-color:#FFFFFF;
text-align: center;
margin: 20px;
}

How to line the boxes up. I am copying this from Jonathan Snook’s page with slight modifications.

#container {
display: table;
border-collapse: separate;
border-spacing: 10px 50px;
}
#row {
display: table-row;
}
#left {
display: table-cell;
padding:20px;
}
#right {
padding:20px;
display: table-cell;
}
#middle {
padding:20px;
display: table-cell;
margin: 60px; /* Not needed. Don't know why I put it here */
}

This is for mobile. If the resolution goes below 797px, the rows go into block mode.
@media all and (max-width:797px) { #row {
display: block;
text-align:center;
}
}

Filed under: CSS

Clean up ScribeInternal DB for Scribe Insight to reduce disk size

If the hard drive on your Scribe Insight integration server gets full, conduct the following operation to reduce the size of the ScribeInternal DB. This database will get full approximately once every 2-3 months.

Procedure:

  1. Run scribemaintenance.sql
  2. Run the following command:
    USE  master
    GO
    EXEC sp_clean_db_free_space @dbname= N'ScribeInternal';
  3. Go to the Object Explorer pane in SSMzS and right click on the database in question. Choose tasks -> shrink -> files. Change the file type option to Log, click the “Reorganize pages before releasing unused space” option, and set the value to 1 MB. Hit OK.

If this doesn’t work, check to see if your database is set up with a Full database recover model. Right click the database and go to properties. Choose Options, and check the Recover model option. Set to simple (if you can!!!), then shrink the logs.

Filed under: ETL

Pareshan Hoon (Bal-e-Jibreel)

پریشان ھوں کے میری خاک آخر دل نا بن جاے
جو مشکل اب ہے یا رب پھر وھی مشکل نا بن جاے

Worry I, that my scattered ashes become a beating heart again.
Those woes that haunted it since, make it fall apart again.

نا کر دیں مجھ کو مجبور نو فردوس میں حوریں
میرا سوز دوران پھر گرمی محفل نا بن جاے

Worry I, the sirens of heaven may tempt me into a song,
The love that burnt timid since, may burst into a blaze.

کبھی چھوڑی ہی منزل بھی یاد آتی ہے راھی کو
کھٹک سی ہے جو سینے میں غم منزل نا بن جاے

Does the wise seafarer ever dwell within his forgone paths? Nay,
But this infliction to you, may become my sorrow fare’s end.

بنایا عشق نے دریا نا پیدا کرنا مجھ کو
یه میری خد نگھداری میرا ساحل نا بن جاے

My love can make my ship run through seas of boundless depths,
But worry I, fear will keep me treading the shallow shores again.

کھین اس علم با رنگ بو میں بھی طلب میری
وھی افسانه دنبالہ محمل نا بن جاے

Does a world full of color and spice, even have a need for me?
Will the passions of this heart of mine echo a forgotten tale.

عروج آدم خاکی سے انجم سہمے جاتے ھیں
کے یه ٹوٹا ھوا مہ کامل نا بن جائے

Panic strikes the stars above, as the feeble Adam rises.
Worry they, this broken star, doesn’t burn a brilliant flame.

Filed under: Other

تاک گلستان

تیری جانب ، اے شہر گل ، نظر بیتاب کھڑی

کھڑی تو ہے ، مگر معلوم ہے بیکار کھڑی

شاید صدا اے گی یہ، کے مجھ سے ہے کچھ کام طلب

اسی خواہش میں مین تیرے در پے ساری رات کھڑی

میرے سینے پر تیری تھامی ہوئی ہتھیلی تھی کبھی

تیری طرز و نظر سنگین، بلاتا تھا دلدار کبھی

آج تیری رہ بھی اور، صحبت یار بھی اور

بےسبب دوران خزاں، تاک گلستان کھڑی

Filed under: Other