Skip to content

Instantly share code, notes, and snippets.

View alex-pat's full-sized avatar

Alexander Pateenok alex-pat

View GitHub Profile
@alex-pat
alex-pat / bin_insert.c
Last active August 29, 2015 14:23
Insert sort of binary file
void bininsert (FILE* f)
{
if (!f) return;
fseek(f, 0, 2);
fpos_t i, j, n = ftell(f);
int tmp, sd;
for ( i = sizeof(int); i < n; i += sizeof(int) )
{
j = i - sizeof(int);
fsetpos(f, &i);
@alex-pat
alex-pat / interflow.cpp
Created June 19, 2015 18:15
interflow of two sorted files (binary)
FILE* interflow(FILE* f1, FILE* f2)
{
if (!f1 || !f2) return NULL;
FILE *f3 = fopen("3","wb");
fseek(f2,0,2);
fseek(f1,0,2);
fpos_t pos1 = 0, pos2;
pos2 = ftell(f2) - sizeof(int);
#!/bin/bash
sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist~ && curl -o /etc/pacman.d/mirrorlist https://www.archlinux.org/mirrorlist/?country=AU
void ignore() {
while ( cin.get() != '\n' );
}
Matrix::Matrix() {
bool firstInput = true;
do {
cin.clear();
if ( firstInput == true )
firstInput = false;
@alex-pat
alex-pat / QDataStream example.cpp
Created December 16, 2015 20:49
QDataStream example
void Manager::saveData() {
QFile settings ("sbsettings");
if ( settings.open ( QIODevice::WriteOnly ) == false ) {
std::cerr << "Cannot open settings" << std::endl;
exit(1);
}
QDataStream stngs (&settings);
int size = profiles.size();
stngs << size
<< currentProfile;
@alex-pat
alex-pat / tree.c
Last active February 16, 2016 22:08
Process tree
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
char* itoa( int number);
int main (int argc, char** argv)
{
@alex-pat
alex-pat / mk.py
Created March 9, 2016 19:55
'make' analog for tasm
#!/usr/bin/env python
# sudo ln -s mk.py /usr/local/bin/mk
## USAGE
## mk lab1
## mk clean lab1
from sys import argv, exit
from os import system
@alex-pat
alex-pat / getch.c
Created March 22, 2016 14:31
getch() for linux
#include <termios.h>
char _getch()
{
struct termios old, new;
char ch;
tcgetattr(0, &old);
new = old;
new.c_lflag &= ~(ICANON | ECHO);
tcsetattr(0, TCSANOW, &new);
@alex-pat
alex-pat / itoa.c
Created April 4, 2016 18:23
itoa function realization
char* itoa( int number)
{
int count = 0;
int copy = number;
do {
count++;
} while ( copy /= 10 );
char* result = (char*) calloc( number+1, 1);
int i = count - 1;
#!/usr/bin/env python3
# 0 -> install matplotlib & numpy & sympy
# tut vse napisano http://matplotlib.org/users/installing.html
# 1 -> Pastnite vashi data iz faila s tipovim v proizvolnu
# 2 -> Kinte fail v papku so skriptom
# 3 -> vizovite skript v duhe ./script_name <poryadkovy nomer grafika iz 10 zadania> <imya faila s dannimy>
# -> gde:
# 1 - F*(x)
# 2 - r'avnointervalnaya functsiya