Skip to content

Instantly share code, notes, and snippets.

View vodolaz095's full-sized avatar

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

View GitHub Profile
@vodolaz095
vodolaz095 / index.js
Last active December 29, 2015 16:38
Working yahoo - oauth - nodejs example
//works on nodejs of 0.10.22
//the WORKING code from there http://developer.yahoo.com/boss/geo/docs/codeexamples.html#oauth_js
//i think YAHOO have to test code before posting
var OAuth = require('oauth'), // `$ npm install oauth`
qs = require('querystring');
function yahooSearch(consumerKey, consumerSecret, query, count, callback){
@vodolaz095
vodolaz095 / cryptoVSmhashBench.js
Last active December 30, 2015 04:29
Crypto vs mhash for hashing some long string
var fs = require('fs'),
crypto = require('crypto'),
mhash = require('mhash').hash, //$ npm install mhash
crc32 = require('buffer-crc32'), //$ npm install buffer-crc32
async = require('async'); //$ npm install async
console.log('Reading file');
var content = fs.readFileSync('./download.htm');
@vodolaz095
vodolaz095 / nginx.conf
Last active January 13, 2016 18:49
NGINX Config for nodejs application with nginx serving assets and socket.io support
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
# * https://gist.github.com/vodolaz095/8373960
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
@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 / 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');