Posts

Showing posts from 2016

android adb command usage

Set system screen off  Set system screen off as never adb shell settings put system screen_off_timeout -1 Set system screen off as 15 seconds adb shell settings put system screen_off_timeout -1 | 15000 Reference :  http://developer.android.com/reference/android/provider/Settings.System.html#SCREEN_OFF_TIMEOUT Start music player Open google play music adb shell am start -n  com.google.android.music/com.android.music.activitymanagement.TopLevelActivity Reference : http://developer.android.com/reference/android/provider/Settings.System.html#SCREEN_BRIGHTNESS Set system screen brightness Set screen backlight as 200 adb shell settings put system screen_brightness 200 Reference : http://developer.android.com/reference/android/provider/Settings.System.html#SCREEN_BRIGHTNESS

Tiling Window Manager Help

Image
What is Tiling Window Manager? Here is the features: Batch start many files and tile windows. Edit the batch tasks.  Tile windows vertically. Tile windows horizontally. Show an about dialog. Install It is a portable executable file. Download and extract the zip file to any folder. Run There are two files in the folder. Double click the executable file  Tiling Window Manager - Press WIN+Q to start.exe It will stay in the system tray. Press WIN+Q combination keys to start the menu of Tiling Window Manager. You can edit the batch tasks by clicking the Manage Shortcuts item. It will open the Shortcuts folder. Move some files into the batch task folder. And rename the batch task folder as any text. I create a batch task folder. The folder name is  Robot Project . Then place two shortcut files index.html and index.js into it. OKay, Now I have a batch task. Press  WIN+Q  combination keys again. The batch task will show in the  menu of Tiling Window Manager. Clic

How to write data into a excel file using vbscript

' This sentence is not work. 'Option Explicit Dim objExcel, strExcelPath, objSheet ' You need to create the Example.xls file first. strExcelPath = "c:\Scripts\Example.xls" ' Open specified spreadsheet and select the first worksheet. Set objExcel = CreateObject("Excel.Application") objExcel.WorkBooks.Open strExcelPath Set objSheet = objExcel.ActiveWorkbook.Worksheets(1) ' Modify a cell. row 3, col 2 objSheet.Cells(3, 2).Value = "Test" ' Add a row before row 5. objSheet.Range("B5").EntireRow.Insert ' Label the new rows. Row 4 is unchanged, ' but what was row 5 is now row 6. objSheet.Cells(4, 2).Value = "Row 4" objSheet.Cells(5, 2).Value = "Row 5" objSheet.Cells(6, 2).Value = "Row 6" ' Save and quit. objExcel.ActiveWorkbook.Save objExcel.ActiveWorkbook.Close objExcel.Application.Quit Check the file exist. If you want to do this. strFile = "c:\Scripts\Report.txt ' C

How to pass arguments into a batch file

The batch file is echo %1 echo %2 Save this file as arguments.bat . In the command line we can type this command arguments.bat arg1 arg2 . It will output arg1 arg2 Reference http://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-to-a-batch-file

Format date as yyyy-mm-dd using vbscript

Function GetFormattedDate strDate = CDate(Date) strDay = DatePart("d", strDate) strMonth = DatePart("m", strDate) strYear = DatePart("yyyy", strDate) If strDay < 10 Then strDay = "0" & strDay End If If strMonth < 10 Then strMonth = "0" & strMonth End If GetFormattedDate = strYear & "-" & strMonth & "-" & strDay End Function 'For example: the date string will be 2011-03-21 GetFormattedDate() Reference http://www.w3schools.com/vbScript/func_formatdatetime.asp

How to declare a global variable in vbscript

Global variable: a variable is outside of any function or sub function Dim x Function y(a) x = x+a y=x End Function Reference http://arstechnica.com/civis/viewtopic.php?t=905411

How to make Google Chrome faster

Image
Back to the default settings After I finish all steps, my settings page become blank and auto refresh never stop. I reinstall the chrome browser then the settings page appears again. Now, you can back to the default settings, it will give you a stable chrome browser. Go to the location  chrome://flags. Click the "Reset all to default" button at the right side. Then click the "Relaunch" button to restart your browser. Go to the location  chrome://settings . Click the  "Reset settings"  button at the bottom side of the page. Clear browsing data Every month you should clear your browsing data. Because the browsing data will make you browse site faster. So you don't clear these every day. You can clear it for privacy reason. Hit Ctrl+H . Click the "Clear browsing data..." button. Check these options Browsing history Download history Cookies and other site and plugin data Cached images and files Hosted app data Click

How to get the output of a command using batch script

@ECHO OFF IF NOT "%1"=="" GOTO ADDV SET VAR= FOR /F %%I IN ('DIR *.TXT /B /O:D') DO CALL %0 %%I SET VAR GOTO END :ADDV SET VAR=%VAR%!%1 :END Reference  http://stackoverflow.com/questions/108439/how-do-i-get-the-result-of-a-command-in-a-variable-in-windows

How to write variable to a file using batch script

echo %PATH%>path.txt Reference http://www.computerhope.com/forum/index.php?topic=105873.0

How to set the path of a batch script as a start directory

cd /d %~dp0 Set StartInDirectory=%CD% Reference http://stackoverflow.com/questions/3827567/how-to-get-the-path-of-the-batch-script-in-windows

How to remove line break in a string using vbscript

Function LineBreak(myString) If Len(myString) <> 0 Then If Right$(myString, 2) = vbCrLf Or Right$(myString, 2) = vbNewLine Then LineBreak= Left$(myString, Len(myString) - 2) End If End If End Function Reference http://stackoverflow.com/questions/10024402/how-to-remove-line-break-in-string

How to get a index of a string using vbscript

InStr(str, " ") Reference http://stackoverflow.com/questions/25083757/how-to-get-the-index-of-a-string-after-the-first-space-in-vbsript

How to disable the maximize button of a popup window

You can do that. The action is restricted by the browser. Reference http://stackoverflow.com/questions/21304807/how-to-disable-the-maximize-button-in-window-open-popup-for-chrome

C# decompiler

Download ILSpy_Master_2.3.1.1855_Binaries

7z unzip command

unzip archive.zip and preserve directory structures in archives. 7z x archive.zip Reference 7z commnd example  7z download  7z command download

show a browse folder dialog to select all files in a specified directory recursively in JavaScript

I think I can get the folder name from the browse folder dialog. But I can't do that because of a security reason . So how can I get the folder name. You can create the folder's tar file by 7z command . Then fire the browse folder dialog. Now, you can get the folder's tar file name from the input element. <html> <head> <title>show a browse folder dialog to select all files in a specified directory recursively in JavaScript</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <input type="file" id="fileUpload" directory webkitdirectory multiple> </br> <textarea id="edit" style="height:200px;width:240px"> Click the select file button to select files, then show the select file names. </textarea> <script> $

show a open old file dialog to select files in JavaScript

<html> <head> <title>show a open old file dialog to select files in JavaScript</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <input type="file" id="fileUpload" multiple> </br> <textarea id="edit" style="height:200px;width:240px"> this is a test </textarea> <script> $('input[type=file]').change(function () { var text=""; for(var i=0;i<this.files.length;i++){ text+=this.files[i].name+"\n"; } $('#edit').val(text) }) </script> </body> </html>

capitalize the first letter of string in JavaScript

<html> <head> <title>capitalize the first letter of string in JavaScript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="test()">Capitalize the first letter of string</button> </br> <textarea id="edit" style="height:200px;width:240px"> this is a test </textarea> <script> function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } function test() { var text=document.getElementById("edit").value; document.getElementById("edit").value=capitalizeFirstLetter(text); } </script> </body> </html>

an array contains a object using javascript

<html> <head> <title>an array contains a object using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="test()">clear array</button> </br> <input id="item" type="text" value="a"/> </br> <textarea id="edit" style="height:200px;width:240px"> </textarea> <script> var arr=["a","b","c"]; function test() { var val=document.getElementById("item").value; var text=""; if(contains(arr,val)){ text="["+arr+"] contains "+val; }else{ text="["+arr+"] not contains "+val; } document.getElementById("edit").value+='\n'+text; } function contains(arr,item) { return arr.indexOf(item)>-1; } document.getElemen

clear an array using javascript

<html> <head> <title>clear an array using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="test()">clear array</button> </br> <textarea id="edit" style="height:200px;width:240px"> </textarea> <script> var arr=[1,2,3]; function test() { clearArray(arr); document.getElementById("edit").value=arr; } function clearArray(arr) { arr.length=0; } document.getElementById("edit").value=arr; </script> </body> </html>

add element to another element using javascript

<html> <head> <title>add element to another element using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="test()">add p element into a div element</button> </br> <textarea id="edit" style="height:200px;width:240px"> <p>hello world<span>!</span></p> </textarea> <script> function test() { var el = document.createElement( 'body' ); var edit= document.getElementById("edit"); var div= document.createElement( 'div' ); div.innerHTML =edit.value; addElement(el,div); edit.value=el.innerHTML; } function addElement(father,child) { father.appendChild(child); } </script> </body> </html>

remove element by tag name using javascript

<html> <head> <title>remove element by tag name using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="test()">remove p element</button> </br> <textarea id="edit" style="height:200px;width:240px"> <body> <p>hello world<span>!</span></p> </body> </textarea> <script> function test() { var el = document.createElement( 'html' ); var edit= document.getElementById("edit"); el.innerHTML =edit.value; removeElementByTagName(el,"p"); edit.value=el.innerHTML; } function removeElementByTagName(el,tagName) { var elements=el.getElementsByTagName( tagName ); while (elements[0]) elements[0].parentNode.removeChild(elements[0]); } </script> </body> </html>

remove blank lines using javascript

<html> <head> <title>remove blank lines using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="test()">remove blank lines</button> </br> <textarea id="edit" style="height:200px;width:240px"> line 1 line 2 line 3 </textarea> <script> function test() { var edit= document.getElementById("edit"); edit.value=removeBlankLines(edit.value); } function removeBlankLines(text) { return text.replace(/^\s*[\r\n]/gm,""); } </script> </body> </html>

show html preview in a frame using javascript

<html> <head> <title>show html preview in a frame using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="populateIframe()">Preview</button> </br> <textarea id="edit" style="height:200px;width:200px"> <html> <body> hi </body> </html> </textarea> </br> <iframe id="frame"> </iframe> <script> function populateIframe() { var ifrm = document.getElementById("frame"); ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument; ifrm.document.open(); var content=document.getElementById("edit").value; ifrm.document.write(content); ifrm.document.close();} populateIframe(); </script> </body> </html&

toggle a element by id using javascript

<html> <head> <title>toggle a element by id using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="toggle('hideMe')">Show/hide</button> <div id="hideMe">I want to hide this by pressing the button above</div> <script> function toggle(id) { var e = document.getElementById(id); if (e.style.display == "block" || e.style.display=="") { e.style.display = "none"; } else { e.style.display = "block"; } } </script> </body> </html>

append html to end of body using javascript

<html> <head> <title>append html to end of body using javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="appendHTMLToBody('<p>hello</p>')">append paragraph</button> <script> function appendHTMLToBody(html){ document.body.innerHTML+=html; } </script> </body> </html>

remove a button by click itself

<html> <head> <title>remove a button by click itself</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="remove()">remove me</button> </body> </html>

add,remove,slice items from an array in javascript

<html> <head> <title>add,remove,slice items from an array in javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="push(8)">add</button> <button onclick="pop()">remove</button></br> <button onclick="slice(2,3)">extract the second and the third elements from the array</button></br> <button onclick="slice(2,4)">extract the second and the third and the fourth elements from the array</button> </br> <textarea style="width: 400px;height: 200px;"id="demo"></textarea> <script> var arr=[1,2,3,4]; function push(item) { arr.push(item); document.getElementById("demo").innerHTML =arr; } function pop() { arr.pop(); document.getElementById("demo").innerHTML =arr; } function slice(a,b) { var citrus = arr.slice(a-1,b);

set and get attribute in javascript

<html> <head> <title>set and get attribute in javascript</title> </head> <body style="background:lightgray"> <p>Click the button to test:</p> <button onclick="getBackground()">Get background</button> <button onclick="setBackgroundAsRed()">Set background as red</button> </br> <textarea style="width: 400px;height: 200px;"id="demo"></textarea> <script> function getBackground() { document.getElementById("demo").innerHTML =document.body.getAttribute("style"); } function setBackgroundAsRed() { document.body.setAttribute("style","background:red"); } </script> </body> </html>

randomize an array in javascript

<html> <head> <title>randomize an array in javascript</title> </head> <body> <p>Click the button to test:</p> <button onclick="myFunction()">Randomize an array</button> </br> <textarea style="width: 400px;height: 200px;"id="demo"></textarea> <script> var arr=[1,9,7,5,4]; function myFunction() { shuffle(arr); document.getElementById("demo").innerHTML =arr; } document.getElementById("demo").innerHTML=arr; function shuffle(array) { var currentIndex = array.length, temporaryValue, randomIndex ; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = tempora

generate random integer in javascript

<html> <head> <title>generate random integer in javascript</title> </head> <body> <p>Click the button to test:</p> <button onclick="myFunction()">Generate random integer</button> </br> <textarea style="width: 400px;height: 200px;"id="demo"></textarea> <script> function myFunction() { document.getElementById("demo").innerHTML =generateRandomInt(1,10); } //generate a random number between min(include) and max(include) function generateRandomInt(min,max) { return Math.floor((Math.random() * max) + min); } </script> </body> </html>

parse a html string in javascript

The key is The string you assign to the variable "el.innerHTML" can't contain double quotes character . You can convert the double quotes character to a single quote character. If you assign the html string inside a textarea, it will convert < character to &lt; string and convert > character to &gt; string automatically. So you have to convert these characters back to <,> character. You have to convert the html string to a single line. If the html string has multiple lines with a \n character. <html> <head> <title>parse a html string in javascript</title> </head> <body> <p>Click the button to test:</p> <button onclick="myFunction()">Result</button> </br> <textarea style="width: 400px;height: 200px;"id="demo"><html><head><title>titleTest</title></head><body><a href='test0'>test01</a><

multi lines to one line in javascript

<html> <head> <title>multi lines to one line in javascript</title> </head> <body> <p>Click the button to test:</p> <textarea id="demo"></textarea> <button onclick="myFunction()">Result</button> <script> var text="line1\nline2"; document.getElementById("demo").innerHTML = text; function myFunction() { var str = document.getElementById("demo").innerHTML; var res = text.replace(/\n/g, ''); document.getElementById("demo").innerHTML = res; } </script> </body> </html>

Programming Snippet Help

Image
Welcome to the Programming Snippet Site. There are many type of programming language's snippet. You can run/edit it online (only support html file). And download/view the snippet file. Run html snippet Click the run button on any post with a html tag. It will show a edit box and preview area. Edit the code then click the result button to see the change. Click the HTML ,JS, CSS button to edit this file. Click the Compress button to remove all new line characters of text in the edit box. Click the Copy button to copy all text in the edit box. Download the snippet Click the download button. Download a snippet file that name as the title text. View plain Click the view plain button. It will pop up a view plain window. You can copy all text to the clipboard by clicking the copy button.

load save file using html5

How to change the file extension of a download file? You can modify the second parameter type of the Blob class to any MIME type. A MIME type is mapping a suffix. The suffix is the file extension. Reference the MIME type list to find the suffix that you want to changed. <html> <head> <title>load save file using html5</title> </head> <body> <table> <tr><td>Text to Save:</td></tr> <tr> <td colspan="3"> <textarea id="inputTextToSave" style="width:512px;height:256px"></textarea> </td> </tr> <tr> <td>Filename to Save As:</td> <td><input id="inputFileNameToSaveAs"></input></td> <td><button onclick="saveTextAsFile()">Save Text to File</button></td> </tr> <tr> <td>Select a File to Load:</td> <td><input type="file&q

online c# compiler

http://csharppad.com/

do copy to the clipboard in javascript

<!DOCTYPE html> <html> <head> <title>do copy to the clipboard in javascript</title> <style> </style> </head> <body> <p> <textarea class="js-copytextarea">Hello I'm some text</textarea> </p> <p> <button class="js-textareacopybtn">Copy Textarea</button> </p> <script type="text/javascript"> var copyTextareaBtn = document.querySelector('.js-textareacopybtn'); copyTextareaBtn.addEventListener('click', function(event) { var copyTextarea = document.querySelector('.js-copytextarea'); copyTextarea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; console.log('Copying text command was ' + msg); } catch (err) { console.log('Oops, unable to copy'); } }); </

modify the author's name in the blogger template

Open the blogger template Search post-author in the template You will find these code at the at the second match This is my new name

using bootstrap css

link tag references this link https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css Click Reference: http://getbootstrap.com/getting-started/

window open style using css

<html> <body> <script> function test(){ var win = window.open('','printwindow'); win.document.write('<html><head><title>Print it!</title><link href="styles.css" rel="stylesheet" type="text/css"></link></head><body>'); console.log($("#content").html()); win.document.write($("#content").html()); win.document.write('</body></html>'); win.print(); win.close(); } </script> <button onclick="test()">Open window</button> <textarea id="content"><h1>hello</h1></textarea> </body> </html> Reference: http://stackoverflow.com/questions/21224676/window-open-style-using-css

replace color in an image

using System.Drawing; Color color = Color.Black; //Your desired colour byte r = color.R; //For Red colour Bitmap bmp = new Bitmap(this.BackgroundImage); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { Color gotColor = bmp.GetPixel(x, y); gotColor = Color.FromArgb(r, gotColor.G, gotColor.B); bmp.SetPixel(x, y, gotColor); } } Reference  http://stackoverflow.com/questions/9871262/replace-color-in-an-image-in-c-sharp

console application add "pause" function

using System; using System.Collections.Generic; using System.Text; namespace Pause { class Program { static void Main(string[] args) { Console.WriteLine("Hello"); Console.ReadLine(); //Pause } } }