Skip to content

Instantly share code, notes, and snippets.

View vodolaz095's full-sized avatar

Остроумов Анатолий vodolaz095

View GitHub Profile
@vodolaz095
vodolaz095 / tea.sh
Last active August 29, 2015 13:56
Bash script that helps me make tea - timer with notify-send notifications, work with LXDE desctop
#!/bin/bash
if [ $1 ]
then
echo "Setting timer for $1 minutes";
DELAY=$(echo "scale=4; $1*60+1" | bc)
DTS=$(date +%H:%M:%S)
(sleep $DELAY; notify-send "TeaHelper by Vodolaz095" "$DTS : Tea is ready!") &
else
echo 'Enter how many minutes to wait for tea to be ready'
@vodolaz095
vodolaz095 / fib.js
Created March 4, 2014 18:18
Fibonacci function
function fib(x){
if(x>=0){
switch(x){
case 0:
return 1;
break;
case 1:
return 1;
break;
default:
@vodolaz095
vodolaz095 / redbook.sh
Last active August 29, 2015 14:00
Script to retrieve and store RedNoteBook data files in private git repository
#!/bin/bash
if [ ! -f ~/.rednotebook/recent.lock ]; then
echo 'Pulling from remote repo...'
cd ~/.rednotebook/data
git pull
touch ~/.rednotebook/recent.lock
else
echo 'Pushing to remote repo...'
cd ~/.rednotebook/data
@vodolaz095
vodolaz095 / cryptoGetHashed.js
Created May 5, 2014 18:31
Get hashing algorithms, that are currently in use by onboard nodejs module of crypto
var crypto = require('crypto');
console.log(crypto.getHashes());
@vodolaz095
vodolaz095 / buildCjdns.sh
Created June 14, 2014 19:58
Cjdroute install script for Fedora 20 Linux
#!/bin/sh
#cjdroute(https://github.com/cjdelisle/cjdns) install script for Fedora 20 linux
cd /home/vodolaz095/projects/cjdns
git checkout master
git pull
echo 'Source code pulled!'
/home/vodolaz095/projects/cjdns/do
su -c 'rm -f /bin/cjdroute;
@vodolaz095
vodolaz095 / regenssh.sh
Created February 23, 2015 06:29
Regenerate SSH server keys
#!/bin/sh
ssh-keygen -q -f /etc/ssh/ssh_host_key -N '' -t rsa1
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa -b 521
@vodolaz095
vodolaz095 / gist:1159273
Created August 20, 2011 16:04
Filter ajax post request with message to cp1251 with code filtering
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);
@vodolaz095
vodolaz095 / express.js
Last active December 8, 2015 20:10
Render 1 pixel jpg image using expressjs
'use strict';
var express = require('express');
var app = express();
app.get('/1pixel.jpg', function(req,res){
var
hex1pixeljpeg = 'ffd8ffe000104a46494600010101006000600000ffe1001645786966000049492a0008000000000000000000ffdb00430001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ffdb00430101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ffc00011080001000103012200021101031101ffc400150001010000000000000000000000000000000affc40014100100000000000000000000000000000000ffc40014010100000000000000000000000000000000ffc40014110100000000000000000000000000000000ffda000c03010002110311003f00bf8001ffd9',
buffer1PixelJpeg = new Buffer(hex1pixeljpeg, 'hex');
@vodolaz095
vodolaz095 / backupAndUpload.sh
Created March 2, 2013 20:21
Upload MySQL database to YandexDisk
DATE=`date +%Y-%m-%d--%H-%M-%S`
YaDiskLogin="myName@yandex.ru"
yaDiskPassword="myPass"
MySQLLogin="root"
MySQLPassword="SecReT"
MySQLDB="MyDB"
@vodolaz095
vodolaz095 / gist:5939316
Created July 6, 2013 09:01
nodejs - mysql - json
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));
});