Category Archives: Tips and Tricks

MSSQL: Search all Records of a Database

Hi,

There are times that we need to find something or search all records particular on an unfamiliar database in MSSQL. It is good to know how to query every item as a worst case scenario. I found this online which can help you, just like me, on looking unto a database that has no documentation.

DECLARE
@search_string VARCHAR(100),
@table_name SYSNAME,
@table_schema SYSNAME,
@column_name SYSNAME,
@sql_string VARCHAR(2000)

SET @search_string = ‘Test’

DECLARE tables_cur CURSOR FOR SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ‘BASE TABLE’

OPEN tables_cur

FETCH NEXT FROM tables_cur INTO @table_schema, @table_name

WHILE (@@FETCH_STATUS = 0)
BEGIN
DECLARE columns_cur CURSOR FOR SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = @table_schema AND TABLE_NAME = @table_name AND COLLATION_NAME IS NOT NULL — Only strings have this and they always have it

OPEN columns_cur

FETCH NEXT FROM columns_cur INTO @column_name
WHILE (@@FETCH_STATUS = 0)
BEGIN
SET @sql_string = ‘IF EXISTS (SELECT * FROM ‘ + QUOTENAME(@table_schema) + ‘.’ + QUOTENAME(@table_name) + ‘ WHERE ‘ + QUOTENAME(@column_name) + ‘ LIKE ”%’ + @search_string + ‘%”) PRINT ”’ + QUOTENAME(@table_schema) + ‘.’ + QUOTENAME(@table_name) + ‘, ‘ + QUOTENAME(@column_name) + ””

EXECUTE(@sql_string)

FETCH NEXT FROM columns_cur INTO @column_name
END

CLOSE columns_cur

DEALLOCATE columns_cur

FETCH NEXT FROM tables_cur INTO @table_schema, @table_name
END

CLOSE tables_cur

DEALLOCATE tables_cur

God Bless!

Thanks,
Thomie

Reapply jQuery validate to a Form loaded via AJAX

Here is a quick snippet to apply jQuery validate to a form loaded via AJAX.

 

var form = $(“#youFormIdentifier”);
form.removeData(‘validator’);
form.removeData(‘unobtrusiveValidation’);
$.validator.unobtrusive.parse(form);

 

Then you can now check if it is valid via:

 

var isValid = form.valid();

Convert.ToDateTime Regardless of Culture

Did you upgrade to Windows 10 recently and your MVC website now have an issue under the development phase after it? Then maybe you also experience the same issue that affected your code on IIS. That is becuase Convert.ToDateTime utilizes the machine’s Culture(It changes when you use Windows 10 even you are using the same Country set) to parse a Date time. So to use it regardless of the Culture use the code snippet below.

 

string s = “20.09.2015 10.16.12”;
string expextedFormat = “dd.MM.yyyy HH.mm.ss”;
DateTime d;
bool isValid = DateTime.TryParseExact(s, expextedFormat , CultureInfo.InvariantCulture, DateTimeStyles.None, out d);

 

Hope it helped you as it helped me.

Installing Cordova when under a Proxy

I have been installing cordova on my work machine this passed days and I am really not happy when it failed because it can’t connect to the internet because our proxy is using AD Authentication. I have tried some NTLM proxy but its not working anymore. My alternative was to connect to the internet directly which is something that will work only when I am at home. Thank fully I found a working way to make it happen with a help from github gist.

Here is the modified steps:

  1. Install CNTLM(mirror) in a folder where you have full rights to run it as administrator.
  2. Open cntlm.ini and fill it :Username YOUR_USERNAME
    Domain YOUR_DOMAIN
    Proxy YOUR_PROXY_IP:PORT
    Password YOUR_PASSWORD
    Listen 53128
  3.  Run the CNTLM by running this command on the context of the folder on Step #1
    cntlm -v -f -c "cntlm.ini"
  4. Run the following on your NPM commands on your Node.js window
    npm config set proxy http://localhost:53128
    npm config set https-proxy http://localhost:53128
    npm config set registry http://registry.npmjs.org
  5. Now you can install Cordova without any issue and even install other NPM modules.

Just a CAUTION your password is in plain text. So be reminded to remove it when your working on a multi-developer machine.

God Bless!

Service Oriented Architecture

Service Oriented Architecture is an architecture that make all request bounded on a form of a Service such as APIs. It consist of three different layers as follows:

  • Authorization Server – Responsible on Authorizing and Authenticating Users and encapsulate it on a token.
  • Resource Server – Responsible to give data based on the token that will be given by the Authorization server.
  • Clients – Responsible to request the token on behalf of a user from the Authorization Server and request resources from the Resource Server.

With this kind of architecture developer can make their application compatible to different platform such as Windows, Linux, and Mac OS. Some implementation of this uses some protocols such as OAuth which is implemented in different ways.

Seafile SSL/HTTPS on IIS

Seafile SSL/HTTPS on IIS was a very interesting journey when I was trying to implement such change as it gave me some interesting facts that I have notice not well documented. In this article we will assume that you have already installed a running instance of your Seafile on your Windows Server but was server via HTTP only. So lets get started:

Additional Assumption

  • Seafile is running on its default ports 8000 and 8082
  • You already know how to get a SSL Certificate and Apply it on your SSL

Settings for your Seafile Server

  1. seahub_settings.pyFILE_SERVER_ROOT = ‘https://yourdomain.with.ssl/seafhttp’
  2. seafile.conf
    [fileserver]
    port = 8082[seahub]
    port = 8000
    fastcgi = false
  3. ccnet.confSERVICE_URL = https://yourdomain.with.ssl/

Settings for your IIS Server

  1. Install Application Request Routing Cache for your IIS Server via Web Platform Installer or by getting it on the web
  2. Create a website that will point to yourdomain.with.ssl on port 80 ONLY
  3. Open the web.config that will be created for that website and enter the following configuration<?xml version=”1.0″ encoding=”UTF-8″?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name=”Redirect to HTTPS” enabled=”true” stopProcessing=”true”>
    <match url=”(.*)” />
    <action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>
  4. Create another website that will point to yourdomain.with.ssl on port 443 ONLY
  5. Open the web.config that will be created for that website and enter the following configuration<?xml version=”1.0″ encoding=”UTF-8″?>
    <configuration>
    <location path=”” overrideMode=”Deny”>
    </location>
    <system.webServer>
    <security>
    <requestFiltering allowDoubleEscaping=”true” />
    </security>
    <rewrite>
    <rules>
    <clear />
    <rule name=”Redirect to HTTPS” enabled=”true” stopProcessing=”true”>
    <match url=”(.*)” />
    <conditions logicalGrouping=”MatchAll” trackAllCaptures=”false”>
    <add input=”{HTTPS}” pattern=”^OFF$” />
    </conditions>
    <action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”Permanent” />
    </rule>
    <rule name=”seafilehttp” stopProcessing=”true”>
    <match url=”seafhttp/(.*)” />
    <conditions logicalGrouping=”MatchAll” trackAllCaptures=”false” />
    <action type=”Rewrite” url=”http://127.0.0.1:8082/{R:1}” appendQueryString=”true” logRewrittenUrl=”true” />
    </rule>
    <rule name=”seafile” enabled=”true” stopProcessing=”true”>
    <match url=”(.*)” />
    <conditions logicalGrouping=”MatchAll” trackAllCaptures=”false” />
    <action type=”Rewrite” url=”http://localhost:8000/{R:1}” appendQueryString=”true” logRewrittenUrl=”true” />
    </rule>

    </rules>
    <outboundRules>
    <preConditions>
    <preCondition name=”ResponseIsHtml1″>
    <add input=”{RESPONSE_CONTENT_TYPE}” pattern=”^text/html” />
    </preCondition>
    </preConditions>
    </outboundRules>
    </rewrite>
    <httpErrors errorMode=”DetailedLocalOnly” />
    </system.webServer>
    </configuration>

  6. Next is the critical part that most tutorial missed to include as they don’t reflect the settings on Seafile Configuration.
  7. Now Login to your Seafile Admin Area webpage and navigate to Settings section
  8. On the SERVICE_URL enter https://yourdomain.with.ssl/
  9. On the FILE_SERVER_ROOT enter https://yourdomain.with.ssl/seafhttp
  10. Now you are done and navigation, download, and upload will now work properly.

God Bless!

Thanks,
Thomie

Remote Desktop Manager

Are you like me who is managing a number of Windows Server? And might be maintaining multiple credential for each. I know its hard and you have the capability of saving the password. But remembering those server name or url is not that easy and I think this tool is right for you.

Microsoft has a manager for that and is called Remote Desktop manager. What it do is enable you to save your servers either per item or you may group them and also state a general setting and credential or even specify one for each.

Go ahead and download it at here.

GIT vs TFS vs SVN

Just like you I have wonder what are the difference between the three Source Code top kind Repositories that are available online. So I have decided to create this article to enlighten myself and others who are looking into the distinguishing difference of each so let get started.

GIT
Git is recently very popular with, you guess it right, github.com as it is offering an online free public source code repositories that everyone can use absolutely free. One of the best highlight of this kind of repository is that “Your CLONED repository is actually the repository that can cloned by others with the history along it”. Thats why when you are getting the source code you get it using the command GIT CLONE with the clone on the command.

TFS
We all know that its a Mirsoft product so most user of TFS are Micorosft entusiasth with Licenses at hand. One of the primary reason of choosing this repo server is that it is thighlt integrated with Microsoft product on Visual Studio and some Office Apps. It is also good to point that it is best to use if you are looking into a source control that is not easily unbinable from its source control. Unbindable that you may not easily remove the binding of the Source code from TFS, well at least that is from my experience.

SVN
Previously popular with most users as it used on Google’s Code website and has plenty of server choices that you can freely download and deploy on your on server absolutely free. It has the build in ability to Easily unbind your source code (EXPORT). Though the only downside is that the only source of truth is on the server unlike GIT which you may trigger your CLONED repo as a source of truth and might be a primary reason that some user move from SVN to GIT.

Well this are all based from my experience and some reading. But still don’t limit ourself on this items as there are also some reasons that is not indicated on this article that might be the triggering point of developers on choosing this kind of repository.

God Bless!

Thanks,
Thomie

PhoneGap Installation Guide – Windows

Hi,

Since we need to have a guide for our teammate I have decided that instead of teaching how to install one by one to my colleagues I will create an online user guide so that any other person online that will be also looking for guide will also have the help that they need. So lets get started.

Prerequisites

 

Installation Guide

  1. Install JDK, just proceed with standard installation process.
  2. Install Android Studio, just proceed with standard installation process. Please note that during the installation phase it will also download the Android SDK with is more than 3GB. PLEASE NOTE OF THE SDK INSTALLATION FOLDER AS THIS WILL BE USED ON LATER PROCEDURE.
  3. Install Aptana, just proceed with standard installation process. Please also note that during installation phase it will also download some prerequisite application including Node.js& Git
  4. Go to START and look for Command Prompt and run it as Administrator.
  5. Type the command below and press enter and wait for the installation process to finish. It will take a while depending on your internet connection.
    npm install -g cordova
    npm install -g proto-list
    npm install -g os-tmpdir
    npm install -g os-homedir
    npm install -g are-we-there-yet
    npm install -g gauge
    npm install -g ansi
    npm install -g is-absolute
    npm install -g asap
    npm install -g minimatch
    npm install -g path-is-absolute
    npm install -g validate-npm-package-license
    npm install -g is-builtin-module
    npm install -g concat-stream
    npm install -g json-parse-helpfulerror
    npm install -g block-stream
    npm install -g fstream-ignore
    npm install -g readdir-scoped-modules
    npm install -g debuglog
    npm install -g lodash._baseflatten
    npm install -g lodash._baseuniq
    npm install -g lodash.restparam
    npm install -g unique-slug
    npm install -g phonegap
  6. After the installation close all window.
  7. Restart your Machine.
  8. Go to your SDK folder that is indicated during the installation of the Android Studio.
  9. Run SDK Manager and install most of the needed SDK, you may install all the SDK if you want to be sure. It will take a while to install depending on your internet connection.
  10. Run AVD Manager and create a virtual device.
  11. You may now proceed with the creation of your PhoneGap app.

 

You may also want to take note the following update on the Environment Variable if it is needed on your side.

ANT_HOME=C:\path\to\ant\folder\apache-ant-1.9.4
ANDROID_HOME=C:\path\to\the\folder\of\Android\sdk
JAVA_HOME = C:\Program Files (x86)\Java\jdk1.7.0_79

PATH
Append;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin;%ANT_HOME%\bin

Disable Copy and Paste on RDP

Hi,

I have given a task to research on the web on how to disable RDP’s Copy and Paste of files due to some security issues. The following Steps should be done with Administrator rights.

  1. Open GPEdit.msc on Windows by Pressing Window Key + R
  2. A Window named Local Group Policy Editor will be shown.
  3. Navigate to Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Device and Resource Redirection
    step a
  4. On the Extended Tab double click Do not allow clipboard redirection
  5. A Window named Do not allow clipboard redirection will be shown.
  6. Click Enabled and Click Apply
    step b
  7. Make sure that all users will Log Off and then Login to implement this new settings.
  8. Done

Source
God Bless!

Thanks,
Thomie

Signalr – OnDisconnect(bool stopCalled)

Most of us who are using .Net as our Programming language use Signalr as our Real-Time Framework. And we implement OnDisconnect in most cases to catch clients that have been disconnected. Since then there were no parameter included as an Overload of the said method. Lately on the latest releases by the Signalr team they have included an Overload so that we can distinguish what triggers the disconnection and help us manage our Apps behavior to it.

With this said I have one experience that I want to share as this may also frustrate some people who are counting connected users and having a problem that when their app have multi workers (Web Garden) they app somehow always trigger OnDisconnect even if the user is still connect. So I want to share this findings on how to properly address it.

  1. Make sure that the App is using a Backplane to manage connection on your hub so that the connections are shared on all threads/servers. I use SQLServer.
  2. Make sure to use the Database on counting your list of connection and tagging who is who. Because in memory List even its static will not be shared on a different server (obviously).
  3. Make sure to trigger disconnection action when the OnDisconnect is called with the stopCalled is equal to true.

Let me highlight what is stopCalled is equal to true means.

  1. It returns true if the method on the connection to close is trigger
  2. It returns true if the browser is called
  3. It returns false if the timeout has been met

Hope this instructions will help you manage your site as it help me on our projects.

God Bless!

Thanks,
Thomie

Google’s My Maps

Many of us give other person direction by giving them the location in Google Maps by using a Pointer. But there is a more accurate way to give directions to our peers and love ones.

Introducing Google My Maps. Google My Maps allows you to create your own map with directions, pointers, and even allow collaborations among other Google users. 

In order to start here is a simple step:

  1. Go to Google Maps
  2. Login your Google Account
  3. Create a New Map
  4. Do mapping and pointing
  5. Save, Share, Collaborate

I have use this for my referrals so that they can know the exact way they need to go when they are invited for an interview. I hope this also help you as it help me.

God Bless!

Thanks,

Thomie

[How To] Contacts Online Sync for Reformatted and Lost Android Phone

Have you ever reformatted or lost your loving Android Mobile Phone or even upgraded to the latest model in the market then all of a sudden you’ve lost your precious Contact Number?

Then, you should do the Contacts Online Sync for Reformatted and Lost Android Phone.

  1. Hit the menu button on your phone and select “System Settings.
    Sync Google Contacts With Android Step 1.jpg
  2. Click “Accounts & Sync” in the Settings menu.
    Sync Google Contacts With Android Step 2.jpg
  3. Click on the “g” symbol for Google in the Sync screen once it appears.
    Sync Google Contacts With Android Step 3.jpg
  4. Check the box marked “sync Contacts. It will tell you the last time your contacts were synced to your phone underneath.
    Sync Google Contacts With Android Step 4.jpg
  5. Hit the menu button and click “Sync Now” to add and sync your contacts to your phone.
    Sync Google Contacts With Android Step 5.jpg

Or Follow This Video

Credits to the Steps, Images, and Video to WikiHow

Regular Expression Online Tool

Regular Expression Online Tool

Do you have some regular expression that you want to test online? Then this online tool is for you,

First you will fill up the regular expression and then you will be given two textbox to test it. Thats it.

 

Regular Expression Online Tool

Regular Expression Online Tool

 

Regular Expression Online Tool Link : http://tools.netshiftmedia.com/regexlibrary/

Firefox OS Simulator : A glance

Hi There,

Its bean a very wonderful experience on how to have a simulator just in front of your Browser. You hear it right. The simulator of Firefox OS is on Firefox Browser Itself. No hassle. Just It.

Download it: http://people.mozilla.org/~myk/r2d2b2g/

Other Notes: https://hacks.mozilla.org/2012/11/announcing-the-prototype-firefox-os-simulator/

Source Control with SVN Server

Hi There

It is a best practice to make your project versionized and in control. So I have look unto having a cost efficient way of controlling your code both Microsoft Project and PHP without having to think about licensing and making your project public on Github. Thus Setting up a Source Control with SVN Server will do the trick.

So here are the tools that you may use and I assume that you are using Windows 32/64-Bit as your Platform

  1. Subversion Edge by CollabNet This needs registration but its worth it as its all in one Server (APACHE + SVN Server + Https)
  2. Turtoise SVN This will serve as your client application that will integrate Context Menu Source control
  3. Internet Connection with Static IP (You can get it with some DSL Business Plan)

 That’s it you may want to Look on the given site as they are easy to follow.

Thanks,
Thomie 

Free ASP .NET Hosting

Hi There,

I have been wondering if there are any free ASP.NET hosting. This is best suites to students that needs to have this hosting to either their assignments, projects, or even thesis. Just a note that if there is FREE in a hosting there for they have limitations. So here goes:

  1. https://somee.com/FreeAspNetHosting.aspx
    1. Forced Advertisement
    2. Storage: 150MB
    3. Monthly transfer: 5GB/Month
    4. Web Domain: 1
    5. ASP .NET v1.1-4.0
    6. AJAX v1.0,3.5
    7. Silver Light
    8. MS Access 2003&2007
    9. 1 Mail domain Forwarder
    10. MS SQL(2003,2008,2012): 15MB

Still looking for other option. Will update you soon.

The Android Bug Factory Reset

Hi There,

Just want you to be aware of the Android Bug on some Samsung device, that is the android bug factory reset. This is most likely to happen to people who have TouchWiz Luncher on their loving Android phone. So how that happen? This happend due to the default dialing capability of our mobile phone that is if someone texted you *#06# and try to call that directly from your sms you will directly get your serial  number. 

The same process goes to any USSD codes that your mobile phone understand. So what is that USSD code that we are talking about, that code is *2767*3855#, remember that you should NOT test this if you are not ok to the consequence for having your phone Factory Reset.

So be aware of it. Its in andform, a browser base url, an sms, a QR code, and other else.

Thanks,

ASP Classic Show Their Error Message

Hi There!

Have you get a notifications when ever you experience an error on your script. Especially when you getthe error message:

An error occurred on the server when processing the URL. Please contact the system administrator

If you are developing ASP Classic in IIS 7.+ make sure that your ASP Classic show their error message and not the message above. This will help you in your development especially when an error occurs. This same situation happen to us when developing the said Scripting Language and IIS 7.+ default its error showing message to false. To modify this just follow this steps:

  1. Go to your IIS Manger.
  2. Select the ASP Icon.
  3. Under the Compilation Table open the Debugging Properties
  4. Make the Send Errors to Browser to TRUE
 
 

Android USB Reverse Tethering

Hi There!

This is Thomie and giving you another tip so you a tip. Do you want to use your computers internet to your android but you don’t have a wifi router? Then this Android USB Reverse Reverse Tethering is best for you.

Just a quick tip this needs your Android Phone the following :

  1. It is Rooted
  2. USB Debugging is Enabled
  3. You have connected your phone via USB to your computer.
  4. You have Installed all prerequisite drivers of your android phone.
  5. And lastly you opened the said file you have download.

Credit to http://forum.xda-developers.com/showthread.php?t=1371345 for this  amazing software.