Hello World! - Code Snippets
Use LocalStorage to save data on client machine
// save data with javascript on client machine through HTML5 pages
if (localStorage) {
// LocalStorage is supported!
localStorage.getItem('user', 'John Doe');
var user = localStorage.getItem('user');
} else {
// LocalStorage is not supported by the browser..
// You may need to go for cookies or similar method
}
Click here to view a sample project on GitHub, on localStorage usage.
Java: Build System to compile and run a .java file
{
"cmd": ["javac", "$file_name","&&","java", "$file_base_name"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"shell": true
}
Click here to check out the tutorial on creating your own Build Systems with Sublime Text.
C: Build System to compile and run a .c file
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "&&", "${file_base_name}.exe"],
"selector" : "source.c",
"shell" : true,
"working_dir" : "$file_path"
}
Click here to check out the tutorial on creating your own Build Systems with Sublime Text.
C++: Build System to compile and run a .cpp file
{
"cmd" : ["g++", "$file_name", "-o", "${file_base_name}.exe", "&&", "${file_base_name}.exe"],
"selector" : "source.c",
"shell":true,
"working_dir" : "$file_path"
}
Click here to check out the tutorial on creating your own Build Systems with Sublime Text.
CUDA: Build System to compile and run a .cu file
{
"cmd" : ["nvcc", "$file_name", "-o", "${file_base_name}.exe","-m32" ,"&&", "${file_base_name}.exe"],
"selector" : "source.cu",
"shell":true,
"working_dir" : "$file_path"
}
*note the '-m32' argument. It is used to compile 64-bit cuda in 32-bit cl.exe (of Visual Studio). If any problems come out. Ask them in your comments.
Click here to check out the tutorial on creating your own Build Systems with Sublime Text.
Verilog: Build System to compile and run a .v file
{
"cmd": ["iverilog", "$file_name", "-o", "${file_base_name}.vvp", "&&","vvp", "${file_base_name}.vvp"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.v",
"shell": true,
"working_dir" : "$file_path",
"variants": [
{
"cmd": ["iverilog", "$file_name", "-o", "${file_base_name}.vvp"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.v",
"name": "Verilog Compile"
},
{
"cmd": ["vvp", "${file_base_name}.vvp"],
"name": "Run Verilog"
}
]
}
Click here to check out the tutorial on creating your own Build Systems with Sublime Text.
No comments:
Post a Comment