Skip to content

Instantly share code, notes, and snippets.

View vidul-nikolaev-petrov's full-sized avatar

Видул Петров vidul-nikolaev-petrov

View GitHub Profile
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / checkrig.pl
Last active August 29, 2015 14:02
Restart Miner Rig On Failure
#!/usr/bin/env perl
use strict;
use warnings;
# Monitor and conditionally reboot the rig miner.
# (Uses `coldreboot` instead of `mine restart`.)
# Tested on SMOS 1.2.
# Start configuration.
# 1. name your cards and their minimal Mh/s
#!/bin/bash
nvram set wan_hwaddr=`nvram get def_hwaddr`
ifconfig `nvram get wan_ifname` down
ifconfig `nvram get wan_ifname` hw ether `nvram get def_hwaddr`
ifconfig `nvram get wan_ifname` up
kill -USR2 $(pidof udhcpc) 2> /dev/null
killall udhcpc 2> /dev/null
/usr/sbin/udhcpc -i `nvram get wan_ifname` -p /var/run/udhcpc/pid -s /tmp/udhcpc
# sample usage (crontab):
# 55 11 * * * /home/monitor/bin/email_http_response_code.pl
my $email = 'YOUR EMAIL ADDRESS'; #example: root@google.com
my $website = 'YOUR WEBSITE URL'; #example: http://google.com
my $date_now = localtime;
my $result_http_code = `curl -sL -w '%{http_code} %{url_effective}' '$website' -o /dev/null`;
$result_http_code =~ s/(\S+)$/($1)/;
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / fibonacci.pl
Last active August 29, 2015 14:05
Fibonacci Numbers in Perl
$.++;$.+=$-,$-=$.-$-,print$.,$/for+1..64
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / check_urls.py
Last active June 13, 2017 18:50
Checks Website Urls
# -*- coding: utf-8 -*-
import multiprocessing
import requests
Host = 'http://www.example.com'
Username = 'YOUR USERNAME'
Password = 'YOUR PASSWORD'
Urls = ('about', 'admin', 'newticket'
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / fibonacci.js
Last active August 29, 2015 14:15
Fibonacci up to
function fibonacci(prev, next, stop) {
if (next >= stop) return prev;
try {
fibonacci.cache.push(prev);
}
catch (e) {
if (e.name === 'TypeError') {
fibonacci.cache = [];
}
use strict;
use warnings;
use File::Basename;
list_direcrory(shift, 1);
sub list_direcrory {
my ($root, $c) = @_;
/**
* Check for arbitrage bet.
*
* @class Arbitrage
*/
var Arbitrage = Arbitrage || {};
var args = [];
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / hanoi.js
Last active August 29, 2015 14:17
Tower of Hanoi
/**
* Thst is not the optimal formula, don't use it.
* This is just another solution for the algorithm
* Tower of Hanoi.
*/
if (Array.prototype.last === undefined) {
Array.prototype.last = function () {
return this.length ? this[this.length - 1] : 0;
};
function quickSort(list) {
if (!list.length) return [];
var left = [],
right = [],
center = list[0];
for (var i = 1; i < list.length; i++) {
if (list[i] < center) {
left.push(list[i]);