IT Blog

  • Blog
  • Technology
    • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • 中文中文
    • ENEN
Experience IT
In a World of Technology, People Make the Difference.
CSS

CSS Tricks

Instead of JavaScript, CSS also can do some tricks to make magic happen. CSS can maintain counter variables to inrease the value, and also add some content before and after a block, emphasize first letter of a paragraph, mandatory fields validation, etc. Counters Demo 1 Effect Code <head> <style> body { counter-reset:sec-counter; /* Set "sec-counter" to 0 */ } h2::before { counter-increment:sec-counter; /*Increment "sec-counter" by 1*/ content:"Section " counter(sec-counter) ". "; } </style> </head> <body> <h2>HTML Tutorial</h2> <h2>CSS Tutorial</h2> <h2>JavaScript Tutorial</h2> <h2>Bootstrap Tutorial</h2> <h2>SQL Tutorial</h2> <h2>PHP Tutorial</h2> </body> Demo 2 Effect Code <head> <style> body{ counter-reset:section; /* define counter */ counter-reset:heading; } h1:before{ counter-increment: heading; content:counter(heading) " - "; } h1{ counter-reset: subheading; } h2:before{ content: counter(heading) "." counter(subheading) ") "; counter-increment: subheading; } h2{ counter-reset: section; /* define counter */ } h3:before{ content: counter(heading) "." counter(subheading) "." counter(section) ") "; /*content: counter(section) ": ";*/ counter-increment: section; } </style> </head> <body> <h3>Heading 3, no counter</h3> <h3>Heading 3, no counter</h3> <h1>Heading 1</h1> <h2>Subheading</h2> <h2>Subheading</h2> <h3>Heading 3</h3> <h3>Heading 3</h3> <h1>Heading 1</h1> <h2>Subheading</h2> <h2>Subheading</h2> </body> Demo 3 Effect Code <dhead> <style> ol{ counter-reset: counter; list-style-type: none; } li::before{ counter-increment: counter; content: counters(counter, ".") " "; } </style> </head> <body> <ol> <li>item</li> <li>item</li> <ol> <li>item</li> <li>item</li> <li> <ol> <li>item</li> <li>item</li> <li>item</li> </ol> </li> <li>item</li> </ol> <li>item</li> <li>item</li> </ol> <ol> <!-- restart counter --> <li>item</li> <li>item</li> </ol> </body> Mask Effect Code <head>     <style>         body{             background-color: rgb(124, 156, 216);         }         img{             width:900px;             mask-image:linear-gradient(to top,transparent 25%, rgb(50, 13, 184) 75%);             -webkit-mask-image: linear-gradient(to left,transparent 25%, #000 75%);         }     </style> </head> <body>     <img src="toronto city hall.jpg"> </body> First Letter…

2021-01-24 0 Comments 511 Views 1 Like IT Team Read more
SQL Server

Generating Test Data with SQL Scripts

<<< These scripts were tested on MS SQL Server  2019 >>> From time to time we need to generate huge data for testing. Without any data generating tool we can achieve it by using some SQL Scripts. these scripts are different from regular query scripts. Generate list of data CREATE TABLE #accounts ( fname VARCHAR(20), lname VARCHAR(20)) GO INSERT #accounts VALUES ('Fred', 'Flintstone') GO 1000 SELECT TOP 10 * FROM #accounts fname lname Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone ALTER TABLE #accounts ADD id INT IDENTITY(1,1) SELECT TOP 10 * FROM #accounts GO fname lname     id Fred Flintstone 1 Fred Flintstone 2 Fred Flintstone 3 Fred Flintstone 4 Fred Flintstone 5 Fred Flintstone 6 Fred Flintstone 7 Fred Flintstone 8 Fred Flintstone 9 Fred Flintstone 10 ALTER TABLE #accounts ADD id INT DECLARE @id INT SET @id = 0 UPDATE #accounts SET @id = id = @id + 1 OPTION ( MAXDOP 1 ) GO SELECT * FROM #accounts GO fname lname     id Fred Flintstone 1 Fred Flintstone 2 Fred Flintstone 3 Fred Flintstone 4 Fred Flintstone 5 Fred Flintstone 6 Fred Flintstone 7 Fred Flintstone 8 Fred Flintstone 9 Fred Flintstone 10 Note: MAXDOP is max degree of parallelism, set it to 1 to avoid duplicate value if running on multiple processors machine. Read article 1 for detail. Generate sequence numbers Using sys.all_columns table SELECT TOP (1000) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM sys.all_columns Generate huge Rows using CROSS JOIN SELECT ROW_NUMBER()…

2021-01-20 0 Comments 412 Views 0 Like IT Team Read more
Technology

Remote connection to MySQL on SiteGround

1. Install MySQL ODBC Connector. Download it here: https://dev.mysql.com/downloads/connector/odbc/ 2. Run ODBC Search for ODBC Data Source, select 32 or 64 bit based on your OS. My OS is Windows 10 64bit, so I select 64-bit. 3. Add a new DSN Click on Add button to add a new DSN select MySQL ODBC Driver Enter parmeters to the screen. In order to complete the PCI compliance requirements the remote MySQL connection to the server's primary IP is blocked. For establishing a remote MySQL connection to a database you have to use the server's secondary IP. The secondly IP is shown on Remote database access hosts screen. 4. Test connection Click on Test button to verify the connection is working. DONE.  3,186 total views

2021-01-11 0 Comments 759 Views 0 Like IT Team Read more
Wordpress

Hide author information from WordPress

Author information is an important part of a blog, but for some reason you have to hide it. For example, the blog is a result of multiple authors. 1. Simply hide author information using stylesheet. Add custom css (look like the following): .author,.postauthor-container { display:none; visibility:hidden; } .uwp_widget_author_box { display:none; visibility:hidden; } /* UserWP plugin */ 2. Using "Hide/Remove Metadata" plugin 3. Change code The author information is written by theme, so you have to find out the php code location in order to make change. The possible location is on the following files: single.php, content.php, archive.php, index.php, functions.php, template-tags.php For example, in the theme "Twenty Nineteen" the code is on "twentynineteen_posted_by" function in template-tags.php file. Note that, before making any change on the theme code please make a full backup.   Hope this informaiton will help some people :)  14,044 total views

2021-01-03 1 Comments 3288 Views 1 Like IT Team Read more
Wordpress

How to do some trick to improve WordPress performance

There are many ways to improve WordPress performance. But here I would introduce a trick to dramatically improve the page loading speed. Convert to html page As a web page the ultimate content is html code. If we could response in html directly without bothering the server code and database to run the page would be loaded really quick. make sure the web page working as expected use browser developer tool to view the source copy the html source code go to File Manager of the CPanel, manually create folders and index.html file according to the url pathFor example: for url "https://hostlike.com/zh/web-hosting/"create folder /zh/web-hosting/, then create file index.html under the new folder open index.html with file editor paste the copied content to the index.html file save the content. Dynamic content trick If there is dynamic content, e.g. shopping cart item number. We can use JavaScript to update the value. Add the following JavaScript code to the end of index.html content. function getCookie(name) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop().split(';').shift(); } var cart_count = getCookie('woocommerce_items_in_cart'); $('.wcmenucart-details').text(cart_count);  17,740 total views

2020-12-29 2 Comments 7477 Views 1 Like IT Team Read more
Wordpress

Recovering user role in WordPress

The administrator role somehow loss admin privillage, to restore it as an admin, we could update 2 rows information in database easily. The following DML will restore the admin privillage. set @id=1; update wp_usermeta set meta_value='10' where user_id=@id and meta_key='wp_user_level' update wp_usermeta set meta_value='a:1:{s:13:"administrator";b:1;}' where user_id=@id and meta_key='wp_capabilities' The admin role is controlled by user level and capability attributes, and these information are stored in wp_usermeta table. User level: User Level 0 converts to Subscriber User Level 1 converts to Contributor User Level 2 converts to Author User Level 3 converts to Editor User Level 4 converts to Editor User Level 5 converts to Editor User Level 6 converts to Editor User Level 7 converts to Editor User Level 8 converts to Administrator User Level 9 converts to Administrator User Level 10 converts to Administrator Capability: Refer to: Roles and Capabilities for detail information. In wp_usermeta table the meta_value stored as role: Admin:            a:1:{s:13:"administrator";b:1;} Author:           a:1:{s:6:"author";b:1;} Contributor:  a:1:{s:11:"contributor";b:1;} Subscriber:    a:1:{s:10:"subscriber";b:1;}  13,220 total views,  5 views today

2020-12-24 2 Comments 3035 Views 1 Like IT Team Read more
Technical Tips

Sending email using gmail SMTP

Gmail allows external users to send email from its SMTP server. You could set it up in gmail settings or google admin settings.

2020-12-22 0 Comments 284 Views 2 Like IT Team Read more
Wordpress

Restrict WordPress user access some contents

Scenario Certain contents are allowed by specific group of users to access. Membership roles concept With Members plugin, user roles can be managed in dashboard. Role permissions are called capability. The capabilities are defined based on themes and plugins. The following figure shows the basic role capabilities. Solution Add a user role that allows users to access those restricted contents. Steps 1. Members plugin Install plugin called "Members – Membership & User Role Editor Plugin". 2. Setup roles Go to Members on the left menu of Dashboard. Here you could add a new role or edit an existing role, and then assign permissions, which called capability within the plugin, to the role. 3. Add user to a role Go to Users menu, click on the user that you want to edit. Scrolldown to the bottom, the last section is User Roles. Select the role to assign. 4. Restrict page access by role On the page/post editor, scrolldown to the last section "Content Permission", assign page with the role that is allowed to access the page/post. Done. Now you have restrict the page to be accessed only the users with the role.  989 total views

2020-12-03 0 Comments 245 Views 0 Like IT Team Read more
Security

Mixed Content warning: request an insecure element was automatically upgraded to HTTPS

After applied SSL settings to enforce HTTPS browser starts complaining "Mixed Content: ..." as the image shown bellow. "Mixed Content" warnings occur when an HTTPS page is asked to load a resource over HTTP. Insecure resources are vulnerable to alteration by an active attacker or eavesdropping by a passive attacker, which violates the user's expectation of security for an HTTPS page. Ref: Fixing mixed content for more information. Fix: Change all insured links with "http://" to "https://" on the page. This could a tough work and time consuming. The following is a hot fix, it works very well for me. Hot fix: Add meta content in html head section to allow browser automatically upgrade http to https, ensure loading contents through SSL layer. <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">  1,275 total views

2020-12-02 0 Comments 293 Views 1 Like IT Team Read more
Hosting

Set up DKIM to prevent email spoofing on GSuite

DomainKeys Identified Mail (DKIM) standard is designed to help prevent spoofing on outgoing messages sent from your domain. Email spoofing is when email content is changed to make the message appear from someone or somewhere other than the actual source. Spoofing is a common unauthorized use of email, so some email servers require DKIM to prevent email spoofing. DKIM adds an encrypted signature to the header of all outgoing messages. Email servers that get signed messages use DKIM to decrypt the message header,  and verify the message was not changed after it was sent. Follow the following steps to setup DKIM on GSuite. Go to google admin console -> apps -> google workspace -> gmail -> Authenticate email -> generate new record -> choose 1024 DKIM bit length -> copy generated domain key -> go to cpanel -> advanced DNS zone editor -> enter the domain key as a text record -> go back to google admin console -> click Start authentication button -> DONE.  2,439 total views

2020-11-27 0 Comments 887 Views 1 Like IT Team Read more
12345…18
Chinese (Simplified) Chinese (Simplified) Chinese (Traditional) Chinese (Traditional) English English French French German German Japanese Japanese Korean Korean Russian Russian
Newest Hotspots Random
Newest Hotspots Random
All Unicode Chars How to keep and display contact form 7 data Common Regular Expressions How to block bad bots in Appache server Add ALT attribute to Social Media Icon Change Event Calendar Title
All Unicode Chars
Send web report by email from report page Show any data in DataTables in WordPress JQuery set selected option for supporting multi-language fix menu arrow Controlling posts order in plugin WP Tab Widget WordPress Sitemap Query
Categories
  • Architecture
  • BI
  • C#
  • CSS
  • Database
  • DotNET
  • Hosting
  • HTML
  • JavaScript
  • PHP
  • Program Language
  • Python
  • Security
  • SEO
  • Technology
  • Web
  • Wordpress

COPYRIGHT © 2021 Hostlike IT Blog. All rights reserved.

This site is supported by Hostlike.com