Feb 18, 2016
Feb 28, 2015
HTML & CSS naming convention – a modern approach
Excerpts original from Stackoverflow
First, if you are not aware of this common (good?) practice: avoid IDs as styling hooks, try to only use Classes
Because:
-
only very few blocks (ie. page-header, page-footer) can 100% garantee the fact that they will not be reused elsewhere
-
you want to keep specificity low, there will always be times you need to override it (without using an extra ID selector or !important)
Common requirements/conventions:
- Names should be intuitive/meaningfull
- Do NOT abbreviate names unless its a really well known abbreviation (ie. msg for Message, accnt for account)
- Use known/common names: .site-nav, .aside-nav, .global-head, .btn-primary, .btn-secondary
- Allow structural hierarchy (ie. BEM convention)
- Use
-or_in namings: probably subjective (devs' opinions) & depending on the keyboard languages used. Note that camelCase has been left aside for browser-compatibility issues I believe, although I never found a proof for this. - Never use elements in selectors unless exceptional case: this allows for more flexibility, ie. you have buttons you created using
<input type="button"></input>and you want to switch to using<button></button>, if you used element types in some selectors then you can plan some annoying/time-consuming refactoring/testing/prod-bug-fixing, whereas if you use element-less selectors then the switch will be infinitely easier. SMACCS also has it in its conventions - For states, try to match known conventions from other languages (php, java, c#): ie, use "is-active", "is-badass", & so on
- Name from left-to-right: from the most generic to the most precise, ie.
btn-bluetheme-create-accntoraccordion-modrnlook-userlist - a class or id name should always be specific enough to be searched across a whole project & return only the relevant results
- Prefer direct descendant if you use descendent selectors - use
.module-name > .sub-module-namevs.module-name .sub-module-name- you'll save yourself some headache in the future (simpler CSS but also more performant, although the term "CSS performance might be laughable")
As discussed below you may want to consider using Structural naming convention OR/AND Presentational naming convention (or skins). I'd prefer the structural one overall but then there always are cases where it's needed (ie. using different button styles on 1 website is not unusual & it might be handy/tempting to name them such as btn-dark & btn-light).
Known conventions:
Structural naming convention: name element's class by describing what it is, rather than where it is or how it looks. See examples below.
.page-container
.page-wrap-header-n-content
.page-header
.branding-logo
.branding-tagline
.wrapper-search
.page-nav-main
.page-main-content
.page-secondary-content
.nav-supplementary
.page-footer
.site-infoPresentational naming convention: name element's class by describing its location and/or appearance. See examples below.
.theme-ocean-blue
.skin-red-tangoBEM naming convention: stands for "Block, Element, Modifier". Syntax is such as <module-name>__<sub-module-name>--<modifier-or-state>. Block is a the "main" container, a kind of module/component whatever you call it. Element is just a child component of the main component (the Block). Modifier is some kind of state. Peculiarities: the syntax (usage of dbl underscore & dbl dash), & child elements must contain their closest component's name. See examples below.
.nav-primary
.nav-primary__list
.nav-primary__item
.nav-primary__link
.nav-primary__link--is-active
.grid
.grid__item
.grid__description
.grid__img-wrap
.grid__img
.global-footer
.global-footer__col
.global-footer__header
.global-footer__linkOCSS naming convention: stands for Object Oriented CSS. Uses skins for branding purposes or consistency of design (ie. bg color, border color, ...). Abstracts the structural styles. Example of abstract structural style below.
.global-width {
min-width: 780px; /* minimum width */
max-width: 1400px; /* maximum width */
margin: 0 auto; /* Centering using margin: auto */
position: relative; /* Relative positioning to create a positioning context for child elements */
padding-left: 20px;
padding-right: 20px;
overflow: hidden; /* Overflow set to "hidden" for clearfixing */
}Some CSS guidelines:
There has been a "trend" to share your CSS styleguide, here are a few you can read to pick & choose whatever seems to fit for your need (naming convention but also much more, this may be out of scope of your question):
- github.com/styleguide/css/
- cssguidelin.es
- css-tricks.com/sass-style-guide
- codepen.io/chriscoyier/blog/codepens-css
Resources:
- http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
- http://www.smashingmagazine.com/2011/12/12/an-introduction-to-object-oriented-css-oocss/
- http://bem.info/method/definitions/
- http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
- http://www.smashingmagazine.com/2011/12/12/an-introduction-to-object-oriented-css-oocss/
- http://www.stuffandnonsense.co.uk/archives/naming_conventions_table.html
- http://sixrevisions.com/css/css-tips/css-tip-2-structural-naming-convention-in-css/
- CSS class naming convention
- Can I use camel-case in CSS class names
- https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Underscores_in_class_and_ID_Names
- http://programmers.stackexchange.com/questions/141988/practical-considerations-for-html-css-naming-conventions-syntax
- http://smacss.com/book/type-module
- github.com/styleguide/css/
- cssguidelin.es
Feb 27, 2015
How to prioritize LAN connection over Wifi (Windows)
On Windows, want to use LAN speedy connection while still connected to wireless ? It’s easy. Here’s how:
1. Open Control Panel –> Network and Internet –> Network Connections
2. In the menu, choose Advanced –> Advanced Settings
3. Use the arrow to move your Local Area Connection to the top. As it’s said: the connections are listed in order which they are accessed by network services.
4. Time to test: I tried copy some files over the network while connected to wi-fi. It works, LAN is used and the speed is much better. Tada !!!
Feb 22, 2015
Hardware hack - how to make your mouse more quiet
Ever feel annoyed by the clicking sound of your mouse, especially at night ? I do. So I just purchase this great Logitech M325 wireless mouse – it has ergonomic build, with contour curve and striped grip that fit nicely on my palm. But the clicking sound is just too much.
OK, my hardware senses are tingling. Let’s find out how to make this mouse more quiet.
Step 1: Open the case
The Logitech wireless mouse M325 is a little bit different from the rest. To open it, you got to remove the battery and the battery label beneath. Then you’ll see a little hidden screw. Remove it
Step 2: Open the click latch
Once you open up your mouse, look for the click latch. Use a penknife, gentle open the latch.
My tips: put the mouse on a black surface. The little white latch on top is very small and it may fly off.
Step 3: Adjust the latch:
Once the latch is opened, you’ll see the latch and the copper switch. Use your knife, put a little pressure to tilt the latch and see if the noise is as quiet as you want. You can use a pen to press on the switch to test.
Before:
After:
That’s it. Now just reassemble everything and enjoy your quiet mouse. Man I could barely hear myself clicking
!
Feb 13, 2015
How to reset applicationhost.config in IIS
Sometime your IIS setting may be corrupted. So you want to reset everything to factory settings.
Here are the steps:
1. In PowerShell, run these commands:
· Get-WindowsFeature
· Uninstall-WindowsFeature Web-Server
· Uninstall-WindowsFeature WAS
2. Using Server Manager: reinstall Web Server (IIS)
3. Open IIS Manager, the applicationhost.config file should be autogenerated.
Feb 5, 2015
IIS unable to start Web Site: HRESULT: 0x80070020 & how to know what is using port 80.
If you hit this error when trying to start your IIS Web:
Take a look at your Windows Event Viewer: it can tell more:
So in my case, it is :unable to bind to port 80. My suspect is some program is using it. Luckily, TCPView from Sysinternals do a great job in reporting port usage.
It turns out Skype is listening on port 80, which prevent IIS from starting up. OK change Skype port and everything is working fine again.
Jan 30, 2015
How to add/remove stored procedure from auto execution in SQL
Using sp_procoption, you can set a stored procedure for auto execution whenever SQL instance start. This is useful if you want to perform a task regularly and need to have it running as a background process.
exec sp_procoption @ProcName = ['stored procedure name'],
@OptionName = 'STARTUP',
@OptionValue = [on|off]
A simple and useful usage is to auto-map the network drive, so that SQL database can be restored from backup files in network drive.
CREATE PROCEDURE sp_AutoMapNetwork AS
BEGIN
EXEC cmd_shell 'NET USE {device} [password]'
END
Jan 7, 2015
Fixing website styles with GreaseMonkey / TamperMonkey
Take a look at this www.runscope.com which provide API testing service. Here is the screenshot in Chrome 39 under Windows 7 64-bit. Their default font is “Source Sans Pro” which somehow look bad:
Then with just a little effort: install TamperMonkey then add the script below, the problem is solved.
// ==UserScript== // @name Change font style of RunScope // @namespace http://diophung.com/ // @version 0.1 // @description Replace RunScope ugly font // @author Dio Phung // @match https://www.runscope.com/* // @grant none // ==/UserScript== //Change the ugly font of RunScope document.body.style.fontFamily = "PT Sans";
Here is how the new www.runscope.com looks like: the font is much easier to read.
Jan 5, 2015
Script to restore MS SQL database from a physical path
In case we want to automate the deployment of a MS SQL database, here is the script.
It will restore a database from a backup file, and store into the folder of your choice.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Dio Phung
-- Create date: 05/01/2015
-- Description: Restore DB from a physical path
-- =============================================
USE [master]
IF EXISTS(SELECT * from sys.[objects] AS o WHERE o.[type]='P' AND o.[name]='sp_RestoreDbFromPath')
BEGIN
DROP PROCEDURE sp_RestoreDbFromPath
END
GO
CREATE PROCEDURE sp_RestoreDbFromPath(
@db_name nvarchar(max), -- The name of the db
@db_source_fullpath NVARCHAR(max), -- path to the backup
@db_dest_folder nvarchar(max) -- folder to store db)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Table TABLE
(
LogicalName VARCHAR(128)
,[PhysicalName] VARCHAR(128)
,[Type] VARCHAR
,[FileGroupName] VARCHAR(128)
,[Size] VARCHAR(128)
,[MaxSize] VARCHAR(128)
,[FileId] VARCHAR(128)
,[CreateLSN] VARCHAR(128)
,[DropLSN] VARCHAR(128)
,[UniqueId] VARCHAR(128)
,[ReadOnlyLSN] VARCHAR(128)
,[ReadWriteLSN] VARCHAR(128)
,[BackupSizeInBytes] VARCHAR(128)
,[SourceBlockSize] VARCHAR(128)
,[FileGroupId] VARCHAR(128)
,[LogGroupGUID] VARCHAR(128)
,[DifferentialBaseLSN] VARCHAR(128)
,[DifferentialBaseGUID] VARCHAR(128)
,[IsReadOnly] VARCHAR(128)
,[IsPresent] VARCHAR(128)
,[TDEThumbprint] VARCHAR(128)
)
DECLARE @LogicalNameData VARCHAR(128),@LogicalNameLog VARCHAR(128)
INSERT INTO @table EXEC ('RESTORE FILELISTONLY FROM DISK=''' + @db_source_fullpath + ''' ')
SET @LogicalNameData = ( SELECT LogicalName FROM @Table WHERE Type = 'D' )
SET @LogicalNameLog = ( SELECT LogicalName FROM @Table WHERE Type = 'L')
DECLARE @RestoreSql nvarchar(max)
SET @RestoreSql = (
'RESTORE DATABASE [' + @db_name +'] FROM DISK = N'''+ @db_source_fullpath+ '''
WITH FILE = 1,
MOVE N'''+ @LogicalNameData+ ''' TO N'''+ @db_dest_folder + '\'+@db_name+'.mdf'',
MOVE N'''+ @LogicalNameLog+ ''' TO N'''+ @db_dest_folder + '\'+@db_name+'_log.ldf'',
NOUNLOAD, REPLACE, STATS = 10
')
SELECT @RestoreSql
EXEC(@RestoreSql)
END
GO
Dec 22, 2014
CSS specificity rules
If you’re reading this, you’re probably looking for how to know which CSS rules are applied. Rule of thumb:
W3C CSS2 specs : the most specific CSS rule is chosen by UA.
How to know the specificity of a CSS ? Refer to the table below
Excerpts from MDN
The specificity is calculated on the concatenation of the count of each selectors type. It is a weight that is applied to the corresponding matching expression.
Ascending order of specificity
| Weight | Selectors | Examples |
| 1 | Universal selectors | * |
| 2 | Type selectors | div |
| 3 | Class selectors | · li.descriptor-link |
| 4 | Attributes selectors | li[attr] |
| 5 | Pseudo-classes | :nth-of-type |
| 6 | ID selectors | #id |
| 7 | Inline style | style=”color:green” |
Notes:
- In case of specificity equality, the latest declaration found in the CSS is applied to the element.
- Proximity of elements in the document tree has no effect on the specificity.
Nov 18, 2014
How to setup a Load Balancer via Application Request Routing (ARR) extension on IIS
This is the walk through on how to set up an Load Balancer on IIS 7.5 using Application Request Routing extension.
Requirements
- IIS (how to install IIS)
- ARR module (download link)
Steps to create Load Balancer
1. Create a dummy web application to receive incoming requests. ![]()
Note: this web app is just a dummy web on port 80, which will acts as request router to our back-end web farm.
2. Configure the dummy web app
In the Create Web Site dialog, use port 80 and the host name as of your domain.![]()
The website physical path can just contains a very simple web.config as following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
</system.web>
</configuration>
3. Create the actual web application that serve your request:
In my example, I used port 8080.
Important notes: this port will be the server port while creating server farm.
![]()
4.Create the server farm
Next step is to create the server farms which will handle the request load balancing. You can choose any name for your server farm.![]()
4. Adding servers to server farm
While adding servers to the farm, take note of the httpPort – this MUST be your web application port which you chose in step 3)![]()
Once you add the server farm, IIS will ask you to add rules. If you have existing rules, it may popup this message. Just go ahead and click Yes to create the rules. We’ll configure it later.
5. Configure the Request Routing rules
Highlight your server farm, then choose Routing Rules![]()
Select URL Rewrite under Advance Routing
6. Configure Inbound Rule Routing Request:
- Logical Grouping: Match All
- Conditions:
- {HTTP_POST} : Matches The Pattern : *localhost* (or your domain name in step 2)
AND - {SERVER_PORT}: Does Not Match The Pattern: *8080* (or your chosen port in step 3)
- Action Type: Route to Server Farm (choose the server farms where you added the web servers in step 4)
7. Configure your Load Balance algorithm
Similar to step 5, highlight your server farm and choose Load Balance
![]()
You will have a list of Load Balance Algorithm to choose from. Depends on your need, you can pick the corresponding algorithm
Use the list to select the algorithm to use to load balance your server. The available options are: (From MSDN):
- Weighted round robin – Distributes traffic based on the number of incoming requests and their normalized weight. Each server can receive the same distribution of requests or a custom distribution.
- Weighted total traffic – Distributes traffic based on the size of the requests and responses in bytes. Requests are routed so that the amount of data is load balanced. In an even distribution, the server with the least amount of data will receive the next request.
- Least current request – Distributes traffic based on the current number of HTTP requests between ARR and each of the application servers. Requests are routed to the server with the least number of current HTTP requests.
- Least response time – Distributes traffic based on the fastest response time from the servers, which enables the server to respond most quickly.
- Server variable hash – Distributes traffic based on a hashed value of a server variable.
- Query string hash – Distributes traffic based on the hashed value of the query string value. When more than one query string name is specified, the concatenated string of the corresponding query string value is used for the hash.
- Request hash – Distributes traffic based on the hashed value of the configured server variable or URL. For example, if the server variable is QUERY_STRING, the hashed value is based on the names in the request query string.
8. Test your server farms to confirm it works
If your configurations are right, you should start to see your web applications running. You can also explore more on configure distributed disk-cache, changing server affinity (how server associate with user sessions) and so on.
Conclusion
The key concept is to create a dummy web application, then use ARR and Load Balance to route request to your server farms (based on the Inbound Rules).
ARR is a very good features which make IIS more useable and become more ready for production sites. Try it yourself and have fun
!
Oct 8, 2014
Useful services and resources for web developer & webmaster
- Docs on GitHub
- MDN
- MSDN
- ReadTheDocs
- Stack Overflow
- w3schools
- WebPlatform.org
- GitHub
- Basecamp
- JIRA
- Trello
- GitHub
- Bitbucket
- Requires.io
- Travis CI
- Bamboo
- Circle CI
- CodeShip
- Code Climate
- Coveralls
- Amazon/EC2
- BlueHost
- DigitalOcean
- DreamHost
- Google/AppEngine
- Heroku
- HostGator
- Linode
- Microsoft/Azure
- Rackspace M
- AppDynamics
- New Relic
- Pingdom
- Scout
- BrowserStack
- SauceLabs
- WAVE/WebAIM
- Flurry
- Google Analytics
- Piwik
- MixPanel
- KISSMetrics
- Adobe Analytics
- Google Analytics
- WebPageTest.org
- Google Analytics (+Content Experiment)
- Optimizely
Jul 14, 2014
How to remove XAMPP from Linux
2. Stop the XAMPP server by typing sudo /opt/lampp/lampp stop in the Terminal (you can open the terminal by pressing Ctrl+Alt+t).
3. Now type sudo rm -rf /opt/lampp4. Check your opt directory. The folder “lampp” would have been removed.
5. You have successfully removed XAMPP from your Ubuntu.
Source: http://coranguweb.wordpress.com/2013/10/31/how-to-uninstall-xampp-from-ubuntu/
Spinner and how to preload background images
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <div id="preloader_wrap"> <div id="spinner_wrap"> <div class="spinner"> <div class="rect1"></div> <div class="rect2"></div> <div class="rect3"></div> <div class="rect4"></div> <div class="rect5"></div> </div> </div> </div> <div id="content">Your content here</div> </body> </html>
CSS:
2. To hide the spinner when your image is loaded:#preloader_wrap { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: #fff; z-index: 999; } #spinner_wrap { width: 200px; height: 200px; position: absolute; left: 50%; top: 50%; background-repeat: no-repeat; background-position: center; margin: -100px 0 0 -100px; } .spinner { margin: 100px auto; width: 50px; height: 30px; text-align: center; font-size: 10px; } .spinner > div { background-color: #2980b9 /*dark blue*/; height: 100%; width: 6px; display: inline-block; -webkit-animation: stretchdelay 1.2s infinite ease-in-out; animation: stretchdelay 1.2s infinite ease-in-out; } .spinner .rect2 { -webkit-animation-delay: -1.1s; animation-delay: -1.1s; } .spinner .rect3 { -webkit-animation-delay: -1.0s; animation-delay: -1.0s; } .spinner .rect4 { -webkit-animation-delay: -0.9s; animation-delay: -0.9s; } .spinner .rect5 { -webkit-animation-delay: -0.8s; animation-delay: -0.8s; } @-webkit-keyframes stretchdelay { 0%, 40%, 100% { -webkit-transform: scaleY(0.4); } 20% { -webkit-transform: scaleY(1.0); } } @keyframes stretchdelay { 0%, 40%, 100% { transform: scaleY(0.4); -webkit-transform: scaleY(0.4); } 20% { transform: scaleY(1.0); -webkit-transform: scaleY(1.0); } }
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> var jpgFile = 'http://farm4.staticflickr.com/3812/11264786296_891530550e_o.jpg'; //or your own picture $("<img/>").attr('src', jpgFile).load(function() { $("#preloader_wrap").hide(); $("body").css("background", "url('" + jpgFile + "') no-repeat center center fixed"); $("#content").show(); }); </script>
Building my own VPS (part 2 )
- Moving to Linode and be aware of unknown VPS providers.
So back to 2013 (about 8 months ago), I decided to go with ReverseHosts but I faced many problems: their servers are slow, downtime was quite often (4-5 times around this year, each time it took several hours), and this thing happened yesterday: their San Diego servers shut down due to business reason ( WTH???), and the only thing I received was an email inform that I will NOT have automatic backup, and I have to request migration to their Las Vegas server.
So I decided to go ahead with linode.com - a well-known VPS provider. I chose Linode 1024 since my demand is minimum.
Well, I was blown away by the speed differences:
root@(none):/etc# wget freevps.us/downloads/bench.sh -O - -o /dev/nul|bash
CPU model : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
Number of cores : 1
CPU frequency : 2800.078 MHz
Total amount of ram : 989 MB
Total amount of swap : 255 MB
System uptime : 2:03,
Download speed from CacheFly: 64.8MB/s
Download speed from Coloat, Atlanta GA: 1.07MB/s
Download speed from Softlayer, Dallas, TX: 34.8MB/s
Download speed from Linode, Tokyo, JP: 12.8MB/s
Download speed from i3d.net, Rotterdam, NL: 3.89MB/s
Download speed from Leaseweb, Haarlem, NL: 9.63MB/s
Download speed from Softlayer, Singapore: 10.2MB/s
Download speed from Softlayer, Seattle, WA: 50.2MB/s
Download speed from Softlayer, San Jose, CA: 59.1MB/s
Download speed from Softlayer, Washington, DC: 24.0MB/s
I/O speed : 770 MB/s
root@(none):/etc# dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync && rm -f test16384+0 records in16384+0 records out1073741824 bytes (1.1 GB) copied, 1.37065 s, 783 MB/s
I/O is superb (as expected on SSD). Cache & network bandwidth are nice, however I notice there are 2 locations with bottleneck : Atlanta GA & Rotterdam, NL.
After 2 hours with Linode, here are some of my comments:
Pros:
- Their Linux setup is on-the-fly, you have plenty of options to setup (Debian, Ubuntu, CentOS...etc) You name it they give it.
- Awesome I/O : 783 MB/s on average ! I copied and movied GBs of data within the VPS and it take seconds.
- Network speed: In general much better than ReserveHosts (except for Altanta node?).
Download speed from Singapore: 10.2MB/s (Softlayer node)
Upload speed from Singapore: 600KB/s (maybe because of my Starhub ISP? Gotta try again tomorrow with better bandwidth).
- More expensive than cheap VPS (well, I guess the stability and speed worth it).
root@(none): mkdir /home/download/devroot@(none): cd /home/download/devroot@(none): wget http://downloads.sourceforge.net/project/xampp/XAMPP%20Linux/1.8.3/xampp-linux-x64-1.8.3-4-installer.run
root@(none): ./xampp-linux-x64-1.8.3-4-installer.run
That's it ! Next step is heading to my name.com account page, and update DNS record, pointing the domain to new IP address.
Good, now I'm back online !!!
May 29, 2014
Use Recycle Bin for network drive (Windows Vista/ 7 / 8)
If you’re working on a network drive and you accidentally delete some files – you’ll realize that this file is not going to the Recycle Bin. NO EASY WAY to recover it!
OMG !
Yeah it happened, and to prevent this disaster from happening to you, please read this guide (courtesy of Russel Riley):
Method 1:
1. Map a network drive to the network share you want to use. Make sure that the drive is re-connected on logon. If you don't know how to do this, search Google.
2. Browse to C:\users\<user name>.
3. Right-click on one of the folders in this location (I chose saved games) and click properties.
4. Select the Location tab.
5. Click Move, browse to to root of the drive you mapped in step 1, and click Select Folder.
6. Click Ok and click yes in the dialogue box that appears.
7. Repeat these same steps for all users on the computer.
Method 2 : the guide is here: http://social.technet.microsoft.com/Forums/windows/en-US/a349801f-398f-4139-8e8b-b0a92f599e2b/enable-recycle-bin-on-mapped-network-drives?forum=w8itpronetworking . In summary:
Create a *.reg file with this content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{9147E464-33A6-48E2-A3C9-361EFD417DEF}]
"RelativePath"="X:\\"
"Category"=dword:00000004
"Name"="XDrive"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\KnownFolder\{9147E464-33A6-48E2-A3C9-361EFD417DEF}]
"MaxCapacity"=dword:0000c7eb
"NukeOnDelete"=dword:00000000
A few things of note:
- The GUID in the above .reg file {9147E464-33A6-48E2-A3C9-361EFD417DEF} came from this PowerShell command: "{"+[guid]::NewGUID().ToString().ToUpper()+"}"
- Each "known folder"/Recycle Bin combination requires a unique GUID. If you don't want to use PowerShell to generate a GUID, you can use an online GUID generator.
- I don't know what the "Category" value does, but the key I copied had it set to 4, and that works, so I didn't test any other values.
- The "Name" value is required, but is not the name that will be shown if you right-click on the Recycle Bin and select properties. (At least not in my environment.) In my environment, the name that is shown is the name of the network drive.
- Making this change adds a "Location" tab to the properties page of your mapped network drives. I suspect this could be removed by changing the "Category" value, but didn't bother to find out.
- I only tested with mapped network drives. I suspect this would work with UNC paths as well, but I didn't bother testing.
Source:
May 14, 2014
HttpUtility.UrlEncode vs. Uri.EscapeDataString vs. UrlPathEncode
How to proper encode and decode values that were passed from Client to Server and vice versa. Client side is using Javascript methods : encodeURI( ) and encodeURIComponent ( ) ?
This seem to be a very fundamental and popular issues – the real complication is when you’re using MVC routing to pass route-data values between controllers. In our solution, we’re using a proprietary method to perform aliasing-dealiasing, which add up more complexity to perform proper value encode/decode.
I’ll update this blog with the solution I found later.
May 10, 2014
Set your password wisely, to remember them easily, for managing multiple accounts securely?
Most popular (and wrong) passwords
An average Internet citizen will have Facebook, Twitter, probably Pinterest or LinkedIn account – and then your Gmail, Yahoo mail, your Internet banking ID, your favourite forum account and the list goes on.
It turns out that most of us choose a common password for every site – what is the implication ? Well, if somebody gains leverage on one of your account.
It’s true that human brain can only process and memorize certain amount of data – that’s why people tend to choose easy password to remember. And it’s wrong, totally WRONG !
Here are the worst and unfortunately most popular 25 passwords in 2012:
# Password Change from 2011
1 password Unchanged
2 123456 Unchanged
3 12345678 Unchanged
4 abc123 Up 1
5 qwerty Down 1
6 monkey Unchanged
7 letmein Up 1
8 dragon Up 2
9 111111 Up 3
10 baseball Up 1
11 iloveyou Up 2
12 trustno1 Down 3
13 1234567 Down 6
14 sunshine Up 1
15 master Down 1
16 123123 Up 4
17 welcome New
18 shadow Up 1
19 ashley Down 3
20 football Up 5
21 jesus New
22 michael Up 2
23 ninja New
24 mustang New
25 password1 New
Is your password in the list ?
If so, read on for my suggestions.
So, how to set password wisely ?
This suggestion below is totally based on my personal experience and I shall not bear any responsibility – OK I am done with disclaimer and if you’re still here, let’s move on:
1. Separate your important accounts from unimportant ones.
For me, I’ll set a separate password for my junk account (forums, secondary Facebook account, Yahoo mail - sorry Yahoo, your spamming filter doesn’t work !).
For important account such as credit card, Paypal, Amazon or banking-related, I’ll pick a different and much longer password.
That way, at least the chance of getting my credit card hacked reduced by 50%.
2. Set your password long & complex enough for hackers
Every password can be crack given enough time with brute-force. According to the calculation at this page, at brute-force speed of 1B guesses/ second (cluster servers, super computing node, or a botnet networks) :
- It’ll be matter of minutes or hours to crack if your password is just pick from alphanumeric values.
- But it’ll take 83.5 days to crack if your password include all possible characters.
which are:
0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz <SP>!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
| Password | Class of Attack | ||||||
| Length | Combinations | ||||||
| 2 | 9,216 | Instant | Instant | Instant | Instant | Instant | Instant |
| 3 | 884,736 | 88½ Secs | 9 Secs | Instant | Instant | Instant | Instant |
| 4 | 85 Million | 2¼ Hours | 14 Mins | 1½ Mins | 8½ Secs | Instant | Instant |
| 5 | 8 Billion | 9½ Days | 22½ Hours | 2¼ Hours | 13½ Mins | 1¼ Mins | 8 Secs |
| 6 | 782 Billion | 2½ Years | 90 Days | 9 Days | 22 Hours | 2 Hours | 13 Mins |
| 7 | 75 Trillion | 238 Years | 24 Years | 2½ Years | 87 Days | 8½ Days | 20 Hours |
| 8 | 7.2 Quadrillion | 22,875 Years | 2,287 Years | 229 Years | 23 Years | 2¼ Years | 83½ Days |
83.5 days on a super computing node to crack a 8-character password ? So let’s make your password AT LEAST 8-CHARACTER LONG !
3. But how to make it memorable to you ?
”Memorable” is a very subjective term and rely heavily on your personal preferences, so I would introduce only a few techniques from Wikihow – find out which one suit you most !
How to store my password securely
Most importantly: do NOT write it down and keep it somewhere – you probably spend more time to find where do you store that piece of paper ![]()
Instead, with the popularity of today’s smartphone, make use of it: http://www.tomsguide.com/us/pictures-story/662-3-best-mobile-password-managers.html
My personal favourite is LastPass – I only wish that them implement finger-print authentication so that I can use it safer on iPhone 5S .
So that’s it – hope you find your own way to create secure and memorable password folks !
Last but not least, even if you come up with the most difficult passwords to crack, you’re still prone “social engineering” !