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
| // https://www.labnol.org/code/19721-add-tags-google-drive-files | |
| /* | |
| setDescriptionToFolderNames | |
| Workaround to fake Tags in Google Drive. | |
| Writes all the folder names of a file into the file description, so that the file can be found by searching the folder names. | |
| */ | |
| function setDescriptionToFolderNames() { | |
| var file; | |
| var filename; |
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
| // Get the canvas and its context | |
| var canvas = document.querySelector('#paint'); | |
| var ctx = canvas.getContext('2d'); | |
| // Get the parent element of the canvas and its computed style | |
| var sketch = document.querySelector('.sketch'); | |
| var sketch_style = getComputedStyle(sketch); | |
| // Set the canvas dimensions to match the parent element | |
| canvas.width = parseInt(sketch_style.getPropertyValue('width')); |
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(window){ | |
| // Define the Pen object, which handles drawing on the canvas | |
| var Pen = function(context){ | |
| // Whether the user is currently drawing | |
| var drawing; | |
| // Reset the pen's drawing style | |
| this.reset = function(){ | |
| context.beginPath(); | |
| context.lineCap = 'round'; |
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
| // given a column 'A'...'AB' etc, return a numeric index | |
| function columnToIndex(column) { | |
| // Initialize the index to 0 | |
| var index = 0; | |
| // Iterate through the characters in the column string | |
| for (var i = 0; i < column.length; i++) { | |
| // Get the character at the current index | |
| var char = column.charAt(i); |
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
| // JSON geocode returned | |
| function doNativeGeoCode(address) { | |
| var response = Maps.newGeocoder().setBounds(32.85964933715685, -117.32946858722974, 32.70248574032382, -117.0346293702513).geocode(address); | |
| return response; | |
| } | |
| // JSON geocode returned | |
| function doApiGeoCode(address) { | |
| var options = { | |
| muteHttpExceptions: true, |
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
| // addresses "Exception: Service invoked too many times for one day: geocode" because the built-in Maps App does not support API keys | |
| // you must create an API key in Maps API in the Google Cloud Console for insertion into Script Properties `mapsApiKey` | |
| function doGeoCode(address) { | |
| var serviceUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${address}&key=${ScriptProperties.getProperty('mapsApiKey')}`; | |
| var response=UrlFetchApp.fetch(serviceUrl, options); | |
| if(response.getResponseCode() == 200) { | |
| var responseJSON = JSON.parse(response.getContentText()); | |
| if (responseJSON !== null) { return responseJSON; } | |
| } |
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
| #!/bin/sh | |
| # v1.0 | |
| wd="/tmp/IPCAM" | |
| mkdir -p $wd | |
| rm -f $wd/* | |
| tar -cf $wd/config.tar -C ./ mnt/mtd |
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
| #!/bin/sh | |
| # FTP_COPY version 0.3 by MP77V www.4pda.ru | |
| # ---------------------------- | |
| FTP_DEST_DIR="/FTP_directory" | |
| FTP_DEST_HOST="FTP_host" | |
| FTP_DEST_PORT="21" | |
| FTP_DEST_LOGIN="FTP_user" | |
| FTP_DEST_PASS="FTP_password" | |
| # ---------------------------- |
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 | |
| from google.cloud import datastore | |
| import google.cloud.exceptions | |
| #https://stackoverflow.com/questions/1593019/is-there-any-simple-way-to-benchmark-python-script | |
| def timereps(reps, func): | |
| from time import time | |
| start = time() | |
| for i in range(0, reps): | |
| func() |
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
| #!/bin/bash | |
| # The MIT License | |
| # | |
| # Copyright (c) 2010, MaDeuce | |
| # | |
| # https://en.wikipedia.org/wiki/MIT_License | |
| # | |
| # ============================================================================ | |
| # This command measures latency and bandwidth of an internet connection from the command line. |