This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// delete file | |
function deleteFile(fileName){ | |
fs.root.getFile(fileName, {create: false}, function(fileEntry) { | |
fileEntry.remove(function() { | |
displayDirectory(); | |
}, errorHandler); | |
}, function(e) { | |
if (e.code == FileError.INVALID_MODIFICATION_ERR){ | |
alert('Filename does not exists'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add content to a file | |
function addContent(existFileName){ | |
fs.root.getFile(existFileName, {}, function(fileEntry) { | |
fileEntry.file(function(file) { | |
var reader = new FileReader(); | |
reader.onloadend = function(e) { | |
var sentContent=prompt("Add contents to the file "+existFileName,this.result); | |
if (sentContent!=null && sentContent!=""){ | |
fileEntry.createWriter(function(fileWriter) { | |
fileWriter.onwriteend = function(trunc) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function displayDirectory(){ | |
var dirReader = fs.root.createReader(); // create reader | |
var entries = []; | |
var readEntries = function() { // new function so you can loop on itself | |
dirReader.readEntries(function(results) { // read all entries saved | |
if (!results.length) { | |
displayFilesAndFolders(entries.sort()); // display all entries saved | |
} else { | |
entries = entries.concat(toArray(results)); | |
readEntries(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function openDb() { | |
var req = indexedDB.open(DB_NAME, DB_VERSION); | |
req.onsuccess = function (evt) { // success connection to the database so display rows | |
db = this.result; | |
displayRows(); | |
}; | |
req.onerror = function (evt) { // error - display error | |
displayActionFailure("DB error: "+ evt.target.errorCode); | |
}; | |
req.onupgradeneeded = function (evt) { // upgrade version has changed so upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addRow(title) { | |
var obj = { title: title }; // structure of the object to save | |
var store = getObjectStore(DB_TABLE_NAME, 'readwrite');// get the object store allowing read and write | |
var req; | |
try { | |
req = store.add(obj); // add row | |
} catch (e) { | |
throw e; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteRow(key) { | |
key = Number(key); // set as number - required to work | |
store = getObjectStore(DB_TABLE_NAME, 'readwrite'); // get the object store allowing read and write | |
var req = store.get(key); // get row from table | |
req.onsuccess = function(evt) { // success - able to get the row from the table | |
var record = evt.target.result; | |
if (typeof record == 'undefined') { // row is empty | |
displayActionFailure("No record found"); | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function displayRows(store) { | |
if (typeof store == 'undefined') | |
store = getObjectStore(DB_TABLE_NAME, 'readonly'); // no table passed so use the default one | |
var listcontainer = $('.listcontainer'); | |
listcontainer.empty(); // clear existing data in the container | |
var req; | |
req = store.count(); | |
req.onsuccess = function(evt) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import gnupg | |
import tarfile | |
import ftplib | |
# create zip file of the folder | |
tar = tarfile.open("docs_backup.tar", "w") | |
tar.add("/home/pi/Documents", arcname="bar") | |
tar.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@red: #BF3130; | |
.red{ | |
background-color:@red; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.red{ | |
background-color:#BF3130; | |
} |