Skip to content

Instantly share code, notes, and snippets.

View spellancer's full-sized avatar

Sarkis Nanyan spellancer

  • Russian Federation
View GitHub Profile
fr = open('input.txt','r')
fw = open('output.txt','w')
line = fr.readline()
a = []
i=0
while len(line)!=0:
line = fr.readline()
i+=1
line = line.split()
if len(line)!=0:
@spellancer
spellancer / gist:7083374
Created October 21, 2013 12:49
For Elena.
#include <iostream> //Подключение библиотеки ввода-вывода
#include <math.h> //Подключение доп.библиотеки с мат. функциями (для вызова fabs() - взятия модуля числа.
using namespace std;
int main() // функция, основная часть программы, где {} - тело функции
{
int a,b,s,max=0,ii; // объявление вспомогательных переменных типа int
// где а и б хранят промежуточные значения, s - хранит сумму цифр текущего элемента массива
// max -- хранит максимальную сумму цифр
fin = open("input.xml", "r")
fout = open("output.xml","w")
a = fin.readlines()
for i in a:
if i.find("<type")!=-1 and i.find("<boot")==-1:
fout.write(i)
fout.write("<boot dev='hd'/>\n")
elif i.find("<kernel>")==-1 and i.find("<initrd>")==-1 and i.find("<cmdline>")==-1:
fin = open("input.xml", "r")
a = fin.readline()
l = ""
kk = False
while len(a)!=0:
a = fin.readline()
if a.find("<kernel>")!=-1 and kk==False:
p = a.find("<kernel>")
for i in range(0,p):
l+= " "
import socket
fr = open ("access.log", "r")
fw = open ("output.txt","w")
c = 0
l = fr.readlines()
for i in l:
a = i.split()
try:
import re
fr = open ("access.log", "r")
fw = open ("output.txt","w")
pipv4 = re.compile ("^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])((\.25[0-5]|\.2[0-4][0-9]|\.1[0-9][0-9]|\.[0-9][0-9]|\.[0-9]){3}) ")
c = 0
l = fr.readlines()
for i in l:
#!/bin/bash
crsa=$(openssl rsa -noout -modulus -in input.txt | openssl md5)
ccer=$(openssl x509 -noout -modulus -in input.txt | openssl md5)
if [ "$crsa" == "$ccer" ]; then
echo "1"
else
echo "0"
fi
#!/bin/bash
check=$(openssl verify input.txt| grep "self signed certificate")
if [ -n "$check" ]; then
echo "1"
else
echo "0"
fi
@spellancer
spellancer / gist:7371670
Created November 8, 2013 14:20
1.py.pki
import subprocess
fout = open("output.txt","w")
s = subprocess.Popen (["openssl","verify","input.txt"], stdout=subprocess.PIPE)
out = s.stdout.read()
if "self signed certificate" in out:
r = 1
else:
r = 0
@spellancer
spellancer / gist:7511384
Created November 17, 2013 09:46
cgroups
import tarfile, re
cpusage = re.compile ("sys/fs/cgroup/cpuacct/lxc/.*/cpuacct.usage$")
ainput = tarfile.open ("input.tgz","r:gz")
res_value = 0
for i in ainput:
if cpusage.search(i.name)!=None:
l = ainput.extractfile(i.name)
current = int(l.readline())
if (current > res_value):