Monday, August 17, 2015

Image hover effects & Customize css for different devices

I. Simple but effective and look good:

[1] http://designshack.net/articles/css/joshuajohnson-2/
[2] http://designshack.net/tutorialexamples/imagehovers/index.html


II. Customize css for different devices. Example:

/* >= 768. Desktop. */
@media only screen and (min-width:768px){
    #slide_img1, #slide_img2, #slide_img3
    {
        display: block; max-width: 100%; height:auto;
    }
}

/* < 768px. Mobile. */
@media only screen and (max-width:768px){
    #slide_img1, #slide_img2, #slide_img3
    {
        display: block; max-width: 800px; height: auto;
    }
}


[3] http://stackoverflow.com/questions/22839792/bootstrap-3-custom-css-class-depending-of-devices

Normalize.css, an alternative to CSS resets

From [1]:

Normalize.css is a small CSS file that provides better cross-browser consistency in the default styling of HTML elements. It’s a modern, HTML5-ready, alternative to the traditional CSS reset.

From [7]:

A CSS Reset (or “Reset CSS”) is a short, often compressed (minified) set of CSS rules that resets the styling of all HTML elements to a consistent baseline.

In case you didn’t know, every browser has its own default ‘user agent’ stylesheet, that it uses to make unstyled websites appear more legible. For example, most browsers by default make links blue and visited links purple, give tables a certain amount of border and padding, apply variable font-sizes to H1, H2, H3 etc. and a certain amount of padding to almost everything. Ever wondered why Submit buttons look different in every browser?

Obviously this creates a certain amount of headaches for CSS authors, who can’t work out how to make their websites look the same in every browser. (NB: article coming soon about why this is a false notion!)

Using a CSS Reset, CSS authors can force every browser to have all its styles reset to null, thus avoiding cross-browser differences as much as possible.


[1] About normalize.css
[2] https://github.com/necolas/normalize.css/
[3] https://necolas.github.io/normalize.css/
[4] Applying Normalize.css Browser Reset CSS (video)

[5] CSS Tools: Reset CSS
[6] http://cssreset.com 2015’s most popular CSS Reset scripts, all in one place.
[7] What Is A CSS Reset?
[8] http://stackoverflow.com/questions/6887336/what-is-the-difference-between-normalize-css-and-reset-css

Monday, August 10, 2015

Paging with SQL

In MySQL, this can be easily done with:

SELECT * FROM tbl limit [start], [end]

In MSSQL, this can be done as in [1] :

1.Paging rows with Limit (MSSQL 2005 or later)

--VIEWING THE PAGE "2" WITH 5 ROWS
DECLARE @PageNumber AS INT, @RowspPage AS INT
SET @PageNumber = 2
SET @RowspPage = 5 SELECT * FROM (
             SELECT ROW_NUMBER() OVER(ORDER BY ID_EXAMPLE) AS NUMBER,
                    ID_EXAMPLE, NM_EXAMPLE, DT_CREATE FROM TB_EXAMPLE
               ) AS TBL
WHERE NUMBER BETWEEN ((@PageNumber - 1) * @RowspPage + 1) AND (@PageNumber * @RowspPage)
ORDER BY ID_EXAMPLE


2. Paging in SQL Server 2012, with FETCH/OFFSET

--CREATING A PAGING WITH OFFSET and FETCH clauses IN "SQL SERVER 2012"
DECLARE @PageNumber AS INT, @RowspPage AS INT
SET @PageNumber = 2
SET @RowspPage = 10 

SELECT ID_EXAMPLE, NM_EXAMPLE, DT_CREATE
FROM TB_EXAMPLE
ORDER BY ID_EXAMPLE
OFFSET ((@PageNumber - 1) * @RowspPage) ROWS
FETCH NEXT @RowspPage ROWS ONLY;


For performance, 2 is better than 1. Both are better than getting all rows and use specific range.

[1] http://social.technet.microsoft.com/wiki/contents/articles/23811.paging-a-query-with-sql-server.aspx


Monday, August 3, 2015

A little Software Engineering - Collect LOC metrics

To manage one's project, one thing is to collect metrics.

To count line of code in all project files, the CLOC [1] command line utility is easy to use.

For example, you can setup a batch file on windows for this purpose. On windows, you can put the cloc.exe executable in C:\windows\ so it's available anywhere in DOS.  Next, in general you need 2 files: 1) a exclude-list file, 2) a batch file to call the CLOC.exe utility.


-- cloc_exclude_list.txt --

c:\inetpub\wwwroot\my_site\backup
c:\inetpub\wwwroot\my_site\images

(Note you cannot put a back slash after the folder name.)


-- run_cloc.bat --

@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
echo Today is: %mydate%
echo.

cloc c:\inetpub\wwwroot\my_site --exclude-list-file=cloc_exclude_list.txt -out=cloc_log\short_%mydate%.txt
cloc c:\inetpub\wwwroot\my_site --exclude-list-file=cloc_exclude_list.txt -out=cloc_log\short_%mydate%.csv --csv

cloc c:\inetpub\wwwroot\my_site --exclude-list-file=cloc_exclude_list.txt --by-file -out=cloc_log\long_%mydate%.txt
cloc c:\inetpub\wwwroot\my_site --exclude-list-file=cloc_exclude_list.txt --by-file -out=cloc_log\long_%mydate%.csv --csv

(This will create 4 output files, for the combination of full/short list and txt/csv format,
prefixed by today's date. So you could setup a schedule task for this to run automatically everyday.)


[1] http://sourceforge.net/projects/cloc/
[2] http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us


Tuesday, July 28, 2015

Bootstrap

== Summary of today's review of Bootstrap ==

Bootstrap is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first web sites. Bootstrap is completely free to download and use!
  • Download from: http://getbootstrap.com
  • Documentation on using JavaScript, CSS and Components are also on the above site.
  • Folder demo/ contains some nice examples of website templates. Good for quick start.
    • demo/assets/js/docs.min.js creates placeholder image. See examples/theme/ for examples.
    • In demo/examples/, for difference of static top and fixed top, you need to view in mobile phone mode.
    • Good ones for mobile: Carousel, cover, Dashboard, Grid, jumbotron-narrow, jumbotron, navbar-fixed-top, navbar-static-top, navbar, signin, sticky-footer-navbar, sticky-footer, theme.
  • Folder tests/ contains some tests of bootstrap.
  • Folder backup/ contains the downloaded boostrap zip distribution package.
  • Folder download/ contains the downloaded entire website of getbootstrap.com.
References:
  1. http://getbootstrap.com
  2. http://www.w3schools.com/bootstrap/

Monday, July 27, 2015

Upload timeout issue

This is a repeated scenario.

Now I'm trying to be as thorough as possible in fixing this.

In PHP, this can be related to the following parameters in php.ini (often /etc/php.ini):

max_execution_time = 60  ; seconds
max_input_time = 60         ; seconds
memory_limit = 512M        ; 0.5 GB
post_max_size = 1000M    ; 1 GB
upload_max_filesize = 1000M   ; 1 GB


If the upload is done through a SOAP client [1], then this parameter in php.ini also should be updated:

default_socket_timeout = 60 ; seconds

After this, apache web server needs restart. (e.g., on redhat, sudo /sbin/service httpd restart)


On windows, ASP.NET application, these parameters in web.config needs update [2]:

In system.web (maxRequestLength is in KB):
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

And in system.webServer (maxAllowedContentLength is in bytes) (this is needed in IIS7 and later): 
<system.webServer>
  
<security>
     
<requestFiltering>
        
<requestLimits maxAllowedContentLength="1073741824" />
     
</requestFiltering>
  
</security>
</system.webServer>


References:
[1] http://stackoverflow.com/questions/9403486/error-fetching-http-headers-in-soapclient
[2] http://stackoverflow.com/questions/3853767/maximum-request-length-exceeded



Windows Domain Controller

On domain controller, show users from console:

dsquery user | sort

Show computers:

dsquery computer

Show help by typing "dsquery":

Description: This tool's commands suite allow you to query the directory
according to specified criteria. Each of the following dsquery commands finds
objects of a specific object type, with the exception of dsquery *, which can
query for any type of object:

dsquery computer - finds computers in the directory.
dsquery contact - finds contacts in the directory.
dsquery subnet - finds subnets in the directory.
dsquery group - finds groups in the directory.
dsquery ou - finds organizational units in the directory.
dsquery site - finds sites in the directory.
dsquery server - finds AD DCs/LDS instances in the directory.
dsquery user - finds users in the directory.
dsquery quota - finds quota specifications in the directory.
dsquery partition - finds partitions in the directory.
dsquery * - finds any object in the directory by using a generic LDAP query.

For help on a specific command, type "dsquery <ObjectType> /?" where
<ObjectType> is one of the supported object types shown above.
For example, dsquery ou /?.

Remarks:
The dsquery commands help you find objects in the directory that match
a specified search criterion: the input to dsquery is a search criterion
and the output is a list of objects matching the search. To get the
properties of a specific object, use the dsget commands (dsget /?).

The results from a dsquery command can be piped as input to one of the other
directory service command-line tools, such as dsmod, dsget, dsrm or dsmove.

Commas that are not used as separators in distinguished names must be
escaped with the backslash ("\") character
(for example, "CN=Company\, Inc.,CN=Users,DC=microsoft,DC=com").

Backslashes used in distinguished names must be escaped with a backslash
(for example,
"CN=Sales\\ Latin America,OU=Distribution Lists,DC=microsoft,DC=com").


Examples:
To find all computers that have been inactive for the last four weeks and
remove them from the directory:

        dsquery computer -inactive 4 | dsrm

To find all users in the organizational unit
"ou=Marketing,dc=microsoft,dc=com" and add them to the Marketing Staff group:

        dsquery user ou=Marketing,dc=microsoft,dc=com | dsmod group
        "cn=Marketing Staff,ou=Marketing,dc=microsoft,dc=com" -addmbr

To find all users with names starting with "John" and display his office
number:

        dsquery user -name John* | dsget user -office

To display an arbitrary set of attributes of any given object in the
directory use the dsquery * command. For example, to display the
sAMAccountName, userPrincipalName and department attributes of the object
whose DN is ou=Test,dc=microsoft,dc=com:

        dsquery * ou=Test,dc=microsoft,dc=com -scope base
        -attr sAMAccountName userPrincipalName department

To read all attributes of the object whose DN is ou=Test,dc=microsoft,dc=com:

        dsquery * ou=Test,dc=microsoft,dc=com -scope base -attr *

Directory Service command-line tools help:
dsadd /? - help for adding objects.
dsget /? - help for displaying objects.
dsmod /? - help for modifying objects.
dsmove /? - help for moving objects.
dsquery /? - help for finding objects matching search criteria.
dsrm /? - help for deleting objects.


Blog Archive

Followers