This file contains 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 filter($a,$ajax=false) | |
{ | |
/* | |
*Filter text messages created by ajax post request to mysql insertions, also all malicious tags (scripts, frames et cetera are removed) | |
*/ | |
if ($ajax) $a=iconv('UTF-8','WINDOWS-1251',urldecode($a)); | |
$a=trim($a); | |
$a=preg_replace('~<script.*>.*</script>~im',NULL,$a); |
This file contains 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 | |
if [ "$1" = '--help' ];then | |
echo 'Usage ./screencast.sh [filename]' | |
else | |
dimensions=`xdpyinfo | grep 'dimensions:'|awk '{print $2}'` | |
if [ -n "$1" ];then | |
outFile="$1" | |
else | |
outFile="$HOME/out.avi" | |
fi |
This file contains 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 | |
# Service watchdog script | |
# Put in crontab to automatially restart services (and optionally email you) if they die for some reason. | |
# Note: You need to run this as root otherwise you won't be able to restart services. | |
# | |
# Example crontab usage: | |
# | |
# Strict check for apache2 service every 5 minutes, pipe results to /dev/null | |
# */5 * * * * sh /root/watchdog.sh apache2 "" > /dev/null | |
# |
This file contains 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
DATE=`date +%Y-%m-%d--%H-%M-%S` | |
YaDiskLogin="myName@yandex.ru" | |
yaDiskPassword="myPass" | |
MySQLLogin="root" | |
MySQLPassword="SecReT" | |
MySQLDB="MyDB" | |
This file contains 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
var ipp = require('ipp'); //get it from there - https://npmjs.org/package/ipp - $npm install ipp | |
var request = require('request'); //get it from there - https://npmjs.org/package/request - $npm install request | |
var fs = require('fs'); | |
function getPrinterUrls(callback) { | |
var CUPSurl = 'http://localhost:631/printers';//todo - change of you have CUPS running on other host | |
request(CUPSurl, function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
var printersMatches = body.match(/<TR><TD><A HREF="\/printers\/([a-zA-Z0-9-^"]+)">/gm);//i know, this is terrible, sorry( | |
var printersUrls = []; |
This file contains 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
var mysql = require('mysql'); | |
var connection = mysql.createConnection({ | |
host : 'example.org', | |
user : 'bob', | |
password : 'secret', | |
}); | |
connection.query('SELECT * FROM `tbl` ORDER BY `id` DESC', function(err, rows) { | |
console.log(JSON.stringify(rows)); | |
}); |
This file contains 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
//A memory cache client for nodeJS | |
//It leaks memory and not scalable, DO NOT USE IN PRODUCTION! | |
//2 methods are utilized | |
// .get(key,function(err,value){}) | |
// .set(key,value,function(err,resultOfSaving){},timeToLiveInMilliseconds) | |
var Storage = {}; | |
exports.get = function (key, callback) { | |
if (Storage[key]) { |
This file contains 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
var express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
res.send('hello world, this is route 1'); | |
}); | |
app.get('/', function(req, res){ | |
res.send('hello world, this is route 2'); | |
}); |
This file contains 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
#.bashrc | |
# Command «unpack» | |
unpack () | |
{ | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xvjf $1 ;; | |
*.tar.gz) tar xvzf $1 ;; | |
*.tar.xz) tar xvJf $1 ;; | |
*.bz2) bunzip2 $1 ;; |
This file contains 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
User "pound" | |
Group "pound" | |
LogLevel 0 | |
LogFacility - | |
Alive 1 | |
TimeOut 10 | |
ListenHTTP | |
Address 0.0.0.0 | |
xHTTP 1 |
OlderNewer