Skip to content

Instantly share code, notes, and snippets.

@haintwork
haintwork / js-best-practices.md
Last active June 12, 2017 07:55 — forked from hemanth/js-best-practices.md
JavaScript best practices

JavaScript Best Practices

Code conventions

Closing/opening brackets

Although this isn't a problem in other languages, because of semicolon insertion, there could be problems if you don't place the bracket on the opening line:

// no:
function()
{
@haintwork
haintwork / 0_reuse_code.js
Created June 12, 2017 07:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@haintwork
haintwork / gist_sublimetext2_code_snippet_management.md
Created June 12, 2017 09:04
Manage code snippet using Gist and SublimeText 2
@haintwork
haintwork / java_rename_file.md
Last active June 12, 2017 09:52
Rename file in java

How to rename file in Java

Java comes with renameTo() method to rename a file. However , this method is really platform-dependent: you may successfully rename a file in *nix but failed in Windows. So, the return value (true if the file rename successful, false if failed) should always be checked to make sure the file is rename successful.

File.renameTo() Example

package com.mkyong.file;

import java.io.File;
@haintwork
haintwork / java7_read_file.java
Last active June 13, 2017 03:44
Read file in Java using FileInputStream
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class ReadFileExample {
public static void main(String[] args) {
File file = new File("C:/robots.txt");
@haintwork
haintwork / java7_write_file.java
Last active November 4, 2019 06:49
[Write file in Java using FileOutputStream] #java #write #file #file_output_stream
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteFileExample {
public static void main(String[] args) {
File file = new File("c:/newfile.txt");
String content = "This is the text content";
@haintwork
haintwork / java_set_read_write_property.java
Created June 13, 2017 03:40
Set file is read only or writable in Java
import java.io.File;
import java.io.IOException;
public class FileReadAttribute
{
public static void main(String[] args) throws IOException
{
File file = new File("c:/file.txt");
@haintwork
haintwork / mysql_service_run_with_no_password_required.md
Last active June 15, 2017 11:49
How to start MySQL with --skip-grant-tables?

Stop the MySQL service through Administrator tools, Services.

Modify the my.ini configuration file (assuming default paths)

C:\Program Files\MySQL\MySQL Server 5.5\my.ini

or for MySQL version >= 5.6

C:\ProgramData\MySQL\MySQL Server 5.6\my.ini 
@haintwork
haintwork / copy_modified_only.bat
Created June 16, 2017 06:21
Copy only modified files and sub folders
xcopy source_folder\* "destination_folder_path" /D /E /C /Q /H /R /Y /K
@haintwork
haintwork / atom_custom_keymap.cson
Created June 17, 2017 02:45
Atom Custom Key Binding
'.platform-win32 atom-text-editor, .platform-linux atom-text-editor':
'ctrl-d': 'editor:delete-line'
'atom-workspace atom-text-editor:not([mini])':
'ctrl-alt-down': 'editor:duplicate-lines',