Skip to content

Instantly share code, notes, and snippets.

View tairov's full-sized avatar

Aydyn Tairov tairov

  • London, UK
View GitHub Profile
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import platform
import random
print "Content-Type: text/html"
rec_cnt = 0
ed_cache = {}
@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
@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 / 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: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
kill -9 $(cat /application/_run/rmq_task*`hostname`*)
@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
#!/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 }')
curl -Ss https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py | sudo python
#
# Hetzner Online AG - installimage
#
# This file contains the configuration used to install this
# system via installimage script. Comments have been removed.
#
# More information about the installimage script and
# automatic installations can be found in our wiki:
#
# http://wiki.hetzner.de/index.php/Betriebssystem_Images_installieren