Skip to content

Instantly share code, notes, and snippets.

View tairov's full-sized avatar

Aydyn Tairov tairov

  • London, UK
View GitHub Profile
#!/bin/bash
#written by akamaras.com
cname=$(cat /proc/cpuinfo|grep name|head -1|awk '{ $1=$2=$3=""; print }')
cores=$(cat /proc/cpuinfo|grep MHz|wc -l)
freq=$(cat /proc/cpuinfo|grep MHz|head -1|awk '{ print $4 }')
tram=$(free -m | awk 'NR==2'|awk '{ print $2 }')
swap=$(free -m | awk 'NR==4'| awk '{ print $2 }')
up=$(uptime|awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }')
cache=$((wget -O /dev/null http://cachefly.cachefly.net/100mb.test) 2>&1 | tail -2 | head -1 | awk '{print $3 $4 }')
@tairov
tairov / smartcheck.sh
Created September 30, 2014 13:19
smartcheck.sh
#!/bin/bash
for DISK in $(ls /dev/sd?);
do echo $DISK;
smartctl -a $DISK| grep -i "Failing now\|Device Model\|Short offline\|Extended Offline\|Reallocated_Sector_Ct\|Offline_Uncorrectable\|Raw_Read_Error_Rate\|Serial Number\|Power_On_Hours\|End-to-End_Error\|Self-test routine in progress...\|remaining";
done
kill -9 $(cat /application/_run/rmq_task*`hostname`*)
@tairov
tairov / gist:11289983
Last active October 29, 2020 16:13
php, rabbitmq, delayed messages
// include the AMQPlib Classes || use an autoloader
// queue/exchange names
$queueRightNow = 'right.now.queue';
$exchangeRightNow = 'right.now.exchange';
$queueDelayed5sec = 'delayed.five.seconds.queue';
$exchangeDelayed5sec = 'delayed.five.seconds.exchange';
$delay = 5; // delay in seconds
@tairov
tairov / run.php
Created April 18, 2014 11:46
run tests script
#!/usr/bin/env php
<?php
function en() {echo join(' ', func_get_args()),PHP_EOL;}
function eln() {echo join(PHP_EOL, func_get_args()),PHP_EOL;}
function runCase($num, $exe, $input, $output, $inData, $expected) {
global $haveErrors;
if ($input != 'stdin') {
$tmpInput = $input;
} else {
@tairov
tairov / gist:9810630
Created March 27, 2014 15:48
cpp, c++, c, read numbers
// Input sequence of numbers
while (1)
{
ch = getchar_unlocked();
if (ch == EOF)
{
// do something with N
break;
}
@tairov
tairov / 0_reuse_code.js
Created March 15, 2014 13:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import platform
import random
print "Content-Type: text/html"
rec_cnt = 0
ed_cache = {}
import java.math.BigInteger;
import java.util.*;
public class A
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
String a=in.next();
String b=in.next();
@tairov
tairov / gist:8996692
Created February 14, 2014 06:35
binadd, php
function binadd($a, $b) {
$n = strlen($a);
$m = strlen($b);
$max = max($n, $m);
$sum = [];
$r = 0;
for ($i = 0; $i < $max; $i++) {
$s = ($n > $i ? $a{$i} : 0) + ($m > $i ? $b{$i} : 0) + $r; $r = 0;
$sum[] = $s & 1 ? '1' : '0';
if ($s > 1) {