Skip to content

Instantly share code, notes, and snippets.

<?php
while(true){
echo date("H:i:s")."<br />".time();
flush();
sleep(1);
}<?php
while(true){
echo date("H:i:s")."<br />".time();
flush();
sleep(1);
#https://stackoverflow.com/questions/1523043/how-to-loop-through-files-and-rename-using-powershell
#https://stackoverflow.com/questions/2038181/how-to-output-something-in-powershell
#https://stackoverflow.com/questions/15113413/how-do-i-concatenate-strings-and-variables-in-powershell
#https://habr.com/ru/post/242445/
#https://stackoverflow.com/questions/39761059/display-file-names
#https://windowsnotes.ru/powershell-2/powershell-i-regulyarnye-vyrazheniya-chast-1/
cls;
$files = Get-ChildItem $(pwd) -Filter *.mp4| select BaseName;
foreach($f in $files)
@bspavel
bspavel / get_element_by_xpath.js
Last active March 5, 2019 09:14
document.getElementByXpath
//https://stackoverflow.com/questions/12689768/how-can-i-extend-the-document-object
//https://stackoverflow.com/questions/10596417/is-there-a-way-to-get-element-by-xpath-using-javascript-in-selenium-webdriver
if (typeof HTMLDocument !== 'undefined') {
HTMLDocument.prototype.getElementByXpath=function (path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
};
} else {
Document.prototype.getElementByXpath=function (path) {
@bspavel
bspavel / ipset_gen.sh
Last active February 28, 2019 12:34
a ipset rule generator from a file
read -p "Input file name: [default: in.txt]:" fileIn
fileIn=${fileIn:-in.txt}
echo $fileIn
read -p "Output file name: [default: block.conf]:" fileOut
fileOut=${fileOut:-block.conf}
echo $fileOut
read -p "Rule name: [default: block]:" ruleName
ruleName=${ruleName:-block}
@bspavel
bspavel / XMLHttpRequest_hook.js
Created February 26, 2019 12:04
Add a “hook” to all AJAX requests on a page
//https://stackoverflow.com/questions/5202296/add-a-hook-to-all-ajax-requests-on-a-page
function addXMLRequestCallback(callback){
var oldSend, i;
if( XMLHttpRequest.callbacks ) {
// we've already overridden send() so just add the callback
XMLHttpRequest.callbacks.push( callback );
} else {
// create a callback queue
XMLHttpRequest.callbacks = [callback];
@bspavel
bspavel / show_a_progress_bar_for_downloading_file.txt
Last active February 18, 2019 22:28
[JAVASCRIPT] Show a progress bar for downloading file
https://stackoverflow.com/questions/39589917/show-a-progress-bar-for-downloading-files-using-xhr2-ajax
If you want to show the user a progress-bar of the downloading process - you must do the download within the xmlhttprequest.
One of the problems here is that if your files are big - they will be saved in the memory of the browser before the browser
will write them to the disk
(when using the regular download files are being saved directly to the disk, which saves a lot of memory on big files).
Another important thing to note - in order for the lengthComputable to be true - your server must send the Content-Length
header with the size of the file.
Here is the javascript code:
@bspavel
bspavel / remote_bash.sh
Created February 11, 2019 18:05 — forked from n0ts/remote_bash.sh
execute bash script from remote site
# http://stackoverflow.com/questions/5735666/execute-bash-script-from-url
bash <(curl -s http://mywebsite.com/myscript.txt)
# http://stackoverflow.com/questions/4642915/passing-parameters-to-bash-when-executing-a-script-fetched-by-curl
curl http://foo.com/script.sh | bash -s arg1 arg2
@bspavel
bspavel / wget.md
Last active January 26, 2019 16:46 — forked from simonw/wget.md
Recursive wget ignoring robots
$ wget -e robots=off -r -np -w1 --content-on-error 'http://example.com/folder/'
  • -e robots=off causes it to ignore robots.txt for that domain
  • -r makes it recursive
  • -np = no parents, so it doesn't follow links up to the parent folder
  • -w wait seconds before downloading next file
  • --content-on-error ignoring errors
@bspavel
bspavel / asterisk_ ffmpeg_installer.sh
Last active May 2, 2019 15:11
the installer of asterisk and ffmpeg on the raspberry pi
#!/bin/bash
#https://codernote.ru/linux-mint/mysql-odbc-v-linux-mint/
#http://morituri.co.nf/raspberry-pi/how-to-compile-ffmpeg-on-a-raspberry-pi-with-x264-mp3-and-aac-encoding/
#https://wiki.asterisk.org/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options
#https://stackoverflow.com/questions/45824220/how-to-run-menuselect-menuselect-command-via-bash-script
#http://forums.asterisk.org/viewtopic.php?f=1&t=77292
#https://app.assembla.com/wiki/show/portaudio/Platforms_RaspberryPi
@bspavel
bspavel / INSTALL.md
Created October 7, 2018 08:17 — forked from arya-oss/INSTALL.md
Ubuntu 16.04 Developer Tools installation

Ubuntu 16.04 Developer Tools Installation

First things first !

sudo apt update
sudo apt upgrade

Standard Developer Tools

sudo apt-get install build-essential git