куча всего

This commit is contained in:
Kolan Sh 2011-04-07 17:03:45 +04:00
parent 7a1219c05e
commit 2e507e65b7
51 changed files with 2954 additions and 0 deletions

4
bash/backup/backup_all Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
#/root/backup_lin
#/root/backup_win

21
bash/backup/backup_lin Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# backups all files in Debian root dir
#bkpdir=/root/penek4_bkp
# Если примонтировать директорию для бакапов в последний раз не удалось,
# то удаляем файлы бакапов, созданные на локальном диске
#rm -f ${bkpdir}/*.deb.tgz
#/usr/bin/fusesmb /root/smb
#bkpdir=/root/smb/MSHOME/BACKBONE/penek4_bkp
bkpdir=/root/penek4_bkp
##smbmount //backbone/penek4_bkp ${bkpdir} -o username=guest,password=guest
#sleep 5
for dir in bin boot etc home initrd lib opt root sbin usr var; do
mv -f "${bkpdir}/${dir}.deb.tgz" "${bkpdir}/${dir}.deb.tgz~"
tar cvz --one-file-system -f "${bkpdir}/${dir}.deb.tgz" "/${dir}"
rm -f "${bkpdir}/${dir}.deb.tgz~"
done;
#umount /root/smb
##smbumount ${bkpdir}
#sleep 5

21
bash/backup/backup_win Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# backups all files in Windows root dir
#bkpdir=/root/penek4_bkp
#Если в последний раз smbmount не сработала
#rm -f $bkpdir/*.xp.tgz
#/usr/bin/fusesmb /root/smb
#bkpdir=/root/smb/MSHOME/BACKBONE/penek4_bkp
bkpdir=/root/penek4_bkp
##smbmount //backbone/penek4_bkp ${bkpdir} -o username=guest,password=guest
##sleep 5
for dir in "WINDOWS"; do
mv -f "$bkpdir/$dir.xp.tgz" "$bkpdir/$dir.xp.tgz~"
tar cvz --one-file-system -f "$bkpdir/$dir.xp.tgz" "/won/$dir"
rm -f "$bkpdir/$dir.xp.tgz~"
done
#umount /root/smb
##smbumount ${bkpdir}
#sleep 5

4
bash/backup/crontab.conf Normal file
View File

@ -0,0 +1,4 @@
SHELL=/bin/bash
MAILTO=root
00 7 */3 * * (/root/backup_all >/dev/null 2>&1)&
00 */3 * * * (/usr/local/sbin/Update >/root/Update.log 2>&1)&

1
bash/bff/1.bff Normal file
View File

@ -0,0 +1 @@
++++++++++[>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++<<<<<<<<<<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.-------------------------------------------------------------------.------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.--------.+++.------.--------.-------------------------------------------------------------------.-----------------------.

1
bash/bff/1.out Normal file
View File

@ -0,0 +1 @@
++++++++++[>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++<<<<<<<<<<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.--------------------------------.++++++++++++++++++++++++++++++++.-------------------------------.+++++++++++++++++++++++++++++++.------------------------------.++++++++++++++++++++++++++++++.-----------------------------.+++++++++++++++++++++++++++++.----------------------------.--------------------------------------------------------------------------------------------------------------------------------------------------------------------------.

1
bash/bff/1.txt Normal file
View File

@ -0,0 +1 @@
++++++++++[>>+<<-]>--------.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>--------------------------------------------------------------------------------.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-------------------------------------------------------------------------------.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.

1
bash/bff/2.out Normal file
View File

@ -0,0 +1 @@
абвгд

4
bash/bff/3.bff Normal file
View File

@ -0,0 +1,4 @@
++[>++[>++[>++[>++[>+++<-] <-] <-] <-] <-] >>>>>+. <+[>+<-] >. <+[>+<-] >.
<+++++++++++++[>++++++++++++<-] >+. . .
<+++++++++++++++++++++++++++++++++++++++++++++++++++++[>---<-] >. <+[>+<-] >.
<+[>+<-] >.

BIN
bash/bff/3.out Normal file

Binary file not shown.

1
bash/bff/4.bff Normal file
View File

@ -0,0 +1 @@
++[>++[>++[>++[>++[>+++++++<-] <-] <-] <-] <-] >>>>>.

1
bash/bff/5.bff Normal file
View File

@ -0,0 +1 @@
++[>++[>++[>++[>++<-] <-] <-] <-] >>>><+++++[>++++++++<-] >. <+++++++[>++++<-] >+. <+++[>++<-] >+. . <++[>+<-] >+. <+++++++++++[>------<-] >-. <+++[>----<-] >. <+++++++++++++++++++++++++++++[>+++<-] >. <++[>----<-] >. <++[>+<-] >+. <+++[>--<-] >. <++[>----<-] >. <+++++++++++[>------<-] >-. <+++++++[>+++++++++++++++++++++++++<-] >. <++[>----------------<-] >.

33
bash/bff/bf2c.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/awk -f
# a brainfuck to C translator.
# Needs a recent version of gawk, if on OS X,
# try using Fink's version.
#
# steve jenson
BEGIN {
print "#include <stdio.h>\n";
print "int main() {";
print " int c = 0;";
print " static int b[30000];\n";
}
{
#Note: the order in which these are
#substituted is very important.
gsub(/\]/, " }\n");
gsub(/\[/, " while(b[c] != 0) {\n");
gsub(/\+/, " ++b[c];\n");
gsub(/\-/, " --b[c];\n");
gsub(/>/, " ++c;\n");
gsub(/</, " --c;\n");
gsub(/\./, " putchar(b[c]);\n");
gsub(/\,/, " b[c] = getchar();\n");
print $0
}
END {
print "\n return 0;";
print "}";
}

1
bash/bff/hello.bff Normal file
View File

@ -0,0 +1 @@
+++++ +++++ initialize counter (cell #0) to 10 [ use loop to set the next four cells to 70/100/30/10 > +++++ ++ add 7 to cell #1 > +++++ +++++ add 10 to cell #2 > +++ add 3 to cell #3 > + add 1 to cell #4 <<<< - decrement counter (cell #0) ] > ++ . print 'H' > + . print 'e' +++++ ++ . print 'l' . print 'l' +++ . print 'o' > ++ . print ' ' << +++++ +++++ +++++ . print 'W' > . print 'o' +++ . print 'r' ----- - . print 'l' ----- --- . print 'd' > + . print '!' > . print '\n'

BIN
bash/bff/kt2bf Executable file

Binary file not shown.

215
bash/bff/kt2bf.cpp Normal file
View File

@ -0,0 +1,215 @@
//---------------------------------------------------------------------------
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
typedef unsigned char UCHAR;
using namespace std;
//---------------------------------------------------------------------------
string sCode;
// Ôàêòîðèçàöèÿ ÷èñëà
vector<int> fucktorize(int numm)
{
if (numm == 1) {
vector<int> v;
v.push_back(1);
return v;
}
int newnum = numm;
vector<int> newtext;
int checker = 2; // First possible factor to check
while (checker *checker <= newnum)
if (newnum % checker == 0) {
newtext.push_back(checker);
newnum = newnum / checker;
} else
checker++;
if (newnum != 1)
newtext.push_back(newnum);
return newtext;
}
// fuck funcktors... íå ïåðåâîäèòñÿ =)
void fuckfucktors(const vector<int>& fucktors, const int i, UCHAR op = 0)
{
if (op == 0)
op = '+';
UCHAR notop = (op == '+') ? '-' : '+';
if (i != 0)
sCode += "[>";
UCHAR tmpop;
if (i != (int)fucktors.size() - 1)
tmpop = '+';
else
tmpop = op;
for (int j = 1; j <= fucktors[i]; j++)
sCode += tmpop;
if (i + 1 < (int)fucktors.size())
fuckfucktors(fucktors, i + 1, op);
if (i != 0)
sCode += "<-] ";
}
int min_val(const string& s)
{
if (s == "")
return -1;
int m = (UCHAR)s[0];
for (size_t i = 1, max_i = s.size(); i < max_i; i++)
if (m > (UCHAR)s[i])
m = (UCHAR)s[i];
return m;
}
int max_val(const string& s)
{
if (s == "")
return -1;
int m = (UCHAR)s[0];
for (size_t i = 1, max_i = s.size(); i < max_i; i++)
if (m < (UCHAR)s[i])
m = (UCHAR)s[i];
return m;
}
// òàêæå ïåðåâîäèòñÿ ñ òðóäîì, íî ýòà ôóíêöèÿ äåëàåò ÷òî-òî ïðèêîëüíîå .)
string brainfuckit(const string &str)
{
string aStr, aStrPrinted;
sCode = "";
if (str == "")
return "";
for (size_t i = 0, max_i = str.length(); i < max_i; i++)
aStr += str[i];
int iMinvalue = min_val(aStr); // *std::min_element(aStr.begin(), aStr.end());
vector<int> fucktors = fucktorize(iMinvalue);
int residuo = 0;
if (fucktors.size() == 1) {
fucktors = fucktorize(iMinvalue - 1);
residuo = 1;
}
fuckfucktors(fucktors, 0);
sCode += " ";
for (size_t i = 0, max_i = fucktors.size() - 1; i < max_i; i++)
sCode += ">";
for (int i = 0; i < residuo; i++)
sCode += "+";
for (size_t i = 0, max_i = aStr.length(); i < max_i; i++) {
if ((UCHAR)aStr[i] == iMinvalue) {
sCode += ". ";
continue;
}
if ((UCHAR)aStr[i] < iMinvalue) {
int x = iMinvalue - (UCHAR)aStr[i];
vector<int> ff = fucktorize(x);
int res = 0;
if ((ff.size() == 1) && (x != 1)) {
x = x - 1;
ff = fucktorize(x);
res = 1;
}
int maxFucktor = *std::max_element(ff.begin(), ff.end());
int complement = x / maxFucktor;
sCode += '<';
vector<int> tmp_v;
tmp_v.push_back(maxFucktor);
tmp_v.push_back(complement);
fuckfucktors(tmp_v, 0, '-');
sCode += ">";
for (int k = 0; k < res; k++)
sCode += "-";
sCode += ". ";
iMinvalue -= iMinvalue - (UCHAR)aStr[i];
continue;
}
if ((UCHAR)aStr[i] > iMinvalue) {
int x = (UCHAR)aStr[i] - iMinvalue;
vector<int> ff = fucktorize(x);
int res = 0;
if ((ff.size() == 1) && (x != 1)) {
x = x - 1;
ff = fucktorize(x);
res = 1;
}
int maxFucktor = *std::max_element(ff.begin(), ff.end());
int complement = x / maxFucktor;
sCode += '<';
vector<int> tmp_v;
tmp_v.push_back(maxFucktor);
tmp_v.push_back(complement);
fuckfucktors(tmp_v, 0, '+');
sCode += ">";
for (int k = 0; k < res; k++)
sCode += "+";
sCode += ". ";
iMinvalue += (UCHAR)aStr[i] - iMinvalue;
continue;
}
}
return sCode;
}
int main(int argc, char *argv[])
{
if (argc != 2) {
cout << "Need string as a parameter to program" <<endl;
cout << "Exiting..." << endl;
return -1;
}
string bff_code = brainfuckit(argv[1]);
cout << bff_code <<endl;
// system("pause");
return 0;
}

1
bash/bff/out2.txt Normal file
View File

@ -0,0 +1 @@
Привет, мир!

BIN
bash/bff/t2bf Executable file

Binary file not shown.

107
bash/bff/t2bf.c Normal file
View File

@ -0,0 +1,107 @@
/*
* Brainfuck String Generator Generator
* A program which takes a string and
* generates a brainfuck code which
* generates the string
* written by the legend: Amir Watad (dot com)
*/
#include <stdio.h>
#include <string.h>
#define N 26
#define MAX_STR_LEN 100000
int main(int argc, char *argv[])
{
unsigned char used[N] = {[0 ... N-1] = -1}; /* saves the state of the
brainfuck array */
unsigned char map[N] = {[0 ... N-1] = -1}; /* a map for fast access to
relevant cells
in the brainfuck array */
unsigned char string[MAX_STR_LEN]; /* input string with a newline in the end */
unsigned char str[MAX_STR_LEN]; /* input string */
int used_idx = 0; /* current place of the brainfuck pointer */
int str_idx = 0; /* index of current unsigned char in the string */
unsigned char current; /* current unsigned char */
int i, j; /* general purpose iterators */
unsigned char c;
if (argc == 2) {
strcpy(str, argv[1]);
} else if (argc == 1) {
i = 0;
while (((c = getchar()) != EOF) && i < MAX_STR_LEN) {
str[i] = c;
i++;
}
} else {
printf("bad number of arguments\n");
return 0;
}
/* copy the input string + a newline */
strcpy(string, str);
string[strlen(str)] = '\n';
string[strlen(str)+1] = '\0';
/* we'll use first index as a counter for the while loop */
used[0] = 10;
printf("++++++++++[");
used_idx = 1;
/* prepare a few places in the brainfuck array
* with values close to those of the unsigned characters
* in the string */
while (current = string[str_idx]) {
if (map[current/10] == -1) {
used[used_idx] = (current/10)*10;
map[current/10] = used_idx;
used_idx++;
}
str_idx++;
}
str_idx = 0;
/* fill the brainfuck array with initial values */
for (i = 1; i < N; i++) {
if (used[i] == -1)
break;
printf(">");
for (j = 0; j < used[i]/10; j++)
printf("+");
}
for (i = 1; i < N; i++) {
if (used[i] == -1)
break;
printf("<");
}
printf("-]");
used_idx = 0;
while (current = string[str_idx]) {
int relevant_idx = map[current/10];
int diff_idx = relevant_idx - used_idx;
int val = used[relevant_idx];
int diff_val = current - val;
used_idx = relevant_idx;
if (diff_idx > 0)
for (i = 0; i < diff_idx; i++)
printf(">");
else
for (i = 0; i > diff_idx; i--)
printf("<");
if (diff_val > 0)
for (i = 0; i < diff_val; i++) {
printf("+");
used[used_idx]++;
}
else
for (i = 0; i > diff_val; i--) {
printf("-");
used[used_idx]--;
}
printf(".");
str_idx++;
}
printf("\n");
return 1;
}

107
bash/bff/t2bf.c.klmn-0 Normal file
View File

@ -0,0 +1,107 @@
/*
* Brainfuck String Generator Generator
* A program which takes a string and
* generates a brainfuck code which
* generates the string
* written by the legend: Amir Watad (dot com)
*/
#include <stdio.h>
#include <string.h>
#define N 26
#define MAX_STR_LEN 100000
int main(int argc, char *argv[])
{
char used[N] = {[0 ... N-1] = -1}; /* saves the state of the
brainfuck array */
char map[N] = {[0 ... N-1] = -1}; /* a map for fast access to
relevant cells
in the brainfuck array */
char string[MAX_STR_LEN]; /* input string with a newline in the end */
char str[MAX_STR_LEN]; /* input string */
int used_idx = 0; /* current place of the brainfuck pointer */
int str_idx = 0; /* index of current char in the string */
char current; /* current char */
int i, j; /* general purpose iterators */
char c;
if (argc == 2) {
strcpy(str, argv[1]);
} else if (argc == 1) {
i = 0;
while (((c = getchar()) != EOF) && i < MAX_STR_LEN) {
str[i] = c;
i++;
}
} else {
printf("bad number of arguments\n");
return 0;
}
/* copy the input string + a newline */
strcpy(string, str);
string[strlen(str)] = '\n';
string[strlen(str)+1] = '\0';
/* we'll use first index as a counter for the while loop */
used[0] = 10;
printf("++++++++++[");
used_idx = 1;
/* prepare a few places in the brainfuck array
* with values close to those of the characters
* in the string */
while (current = string[str_idx]) {
if (map[current/10] == -1) {
used[used_idx] = (current/10)*10;
map[current/10] = used_idx;
used_idx++;
}
str_idx++;
}
str_idx = 0;
/* fill the brainfuck array with initial values */
for (i = 1; i < N; i++) {
if (used[i] == -1)
break;
printf(">");
for (j = 0; j < used[i]/10; j++)
printf("+");
}
for (i = 1; i < N; i++) {
if (used[i] == -1)
break;
printf("<");
}
printf("-]");
used_idx = 0;
while (current = string[str_idx]) {
int relevant_idx = map[current/10];
int diff_idx = relevant_idx - used_idx;
int val = used[relevant_idx];
int diff_val = current - val;
used_idx = relevant_idx;
if (diff_idx > 0)
for (i = 0; i < diff_idx; i++)
printf(">");
else
for (i = 0; i > diff_idx; i--)
printf("<");
if (diff_val > 0)
for (i = 0; i < diff_val; i++) {
printf("+");
used[used_idx]++;
}
else
for (i = 0; i > diff_val; i--) {
printf("-");
used[used_idx]--;
}
printf(".");
str_idx++;
}
printf("\n");
return 1;
}

107
bash/bff/t2bf.c~ Normal file
View File

@ -0,0 +1,107 @@
/*
* Brainfuck String Generator Generator
* A program which takes a string and
* generates a brainfuck code which
* generates the string
* written by the legend: Amir Watad (dot com)
*/
#include <stdio.h>
#include <string.h>
#define N 26
#define MAX_STR_LEN 100000
int main(int argc, char *argv[])
{
unsigned char used[N] = {[0 ... N-1] = -1}; /* saves the state of the
brainfuck array */
unsigned char map[N] = {[0 ... N-1] = -1}; /* a map for fast access to
relevant cells
in the brainfuck array */
unsigned char string[MAX_STR_LEN]; /* input string with a newline in the end */
unsigned char str[MAX_STR_LEN]; /* input string */
int used_idx = 0; /* current place of the brainfuck pointer */
int str_idx = 0; /* index of current unsigned char in the string */
unsigned char current; /* current unsigned char */
int i, j; /* general purpose iterators */
unsigned char c;
if (argc == 2) {
strcpy(str, argv[1]);
} else if (argc == 1) {
i = 0;
while (((c = get (unsigned char())) != EOF) && i < MAX_STR_LEN) {
str[i] = c;
i++;
}
} else {
printf("bad number of arguments\n");
return 0;
}
/* copy the input string + a newline */
strcpy(string, str);
string[strlen(str)] = '\n';
string[strlen(str)+1] = '\0';
/* we'll use first index as a counter for the while loop */
used[0] = 10;
printf("++++++++++[");
used_idx = 1;
/* prepare a few places in the brainfuck array
* with values close to those of the unsigned characters
* in the string */
while (current = string[str_idx]) {
if (map[current/10] == -1) {
used[used_idx] = (current/10)*10;
map[current/10] = used_idx;
used_idx++;
}
str_idx++;
}
str_idx = 0;
/* fill the brainfuck array with initial values */
for (i = 1; i < N; i++) {
if (used[i] == -1)
break;
printf(">");
for (j = 0; j < used[i]/10; j++)
printf("+");
}
for (i = 1; i < N; i++) {
if (used[i] == -1)
break;
printf("<");
}
printf("-]");
used_idx = 0;
while (current = string[str_idx]) {
int relevant_idx = map[current/10];
int diff_idx = relevant_idx - used_idx;
int val = used[relevant_idx];
int diff_val = current - val;
used_idx = relevant_idx;
if (diff_idx > 0)
for (i = 0; i < diff_idx; i++)
printf(">");
else
for (i = 0; i > diff_idx; i--)
printf("<");
if (diff_val > 0)
for (i = 0; i < diff_val; i++) {
printf("+");
used[used_idx]++;
}
else
for (i = 0; i > diff_val; i--) {
printf("-");
used[used_idx]--;
}
printf(".");
str_idx++;
}
printf("\n");
return 1;
}

1
bash/bff/test1.bff Normal file
View File

@ -0,0 +1 @@
++++++++++[>>>++++>+++>+++++++++++>++++++++++>+<<<<<<<-]>--------.<-----------------------------------------------------------------------------------------------------------.>+.>--------.<-.<<<<<<<<<<<<<<<<<<<<<<<<-----------------------------------------------------------------------.>>>>>>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<<<<<<<<<------.>>>>>>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<<<<<<<<<+++.>>>>>>>>>>>>>>>>>>>>>>>>+.>++.>++++.>++.>+++++++++.--------.+++.>++++++++.--------.<<+.>>>.

5
bash/bff/test3.bff Normal file
View File

@ -0,0 +1,5 @@
>++++++++++
[>++++>++++>+++++>+++++>++++++>+++++>++++++>++++>++++>+++++>+++++>++++++>+++++>++++++>++++>++++>+++++>+++++>++++++>+++++>++++++>++++>++++>+++++>+++++>++++++>+++++>++++++>++++>++++>+++++>+++++>++++++>+++++>++++++><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]
>-->----->->-->----->>->-->----->->-->----->+>->-->----->->-->----->++>->-->----->->-->----->+++>->-->----->->-->----->++++>->
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.

40
bash/bff/text2bf.c Normal file
View File

@ -0,0 +1,40 @@
/*
text to brainfuck converter
-- saves any input text inside the brainfuck registers and prints it
all out.
2004-07-22 - BeF <bef@erlangen.ccc.de>
compile hint:
lex -o text2bf.lex.c text2bf.lex.l
cc -pipe -O2 text2bf.lex.c -o text2bf -ll
*/
%{
int prevchar = 0;
%}
%%
(.|\n) {
printf("<[->+>+<<]>>[-<<+>>]<");
if (prevchar < yytext[0])
while (yytext[0]-prevchar++)
putchar('+');
else
while (yytext[0]-prevchar--)
putchar('-');
putchar('>');
prevchar = yytext[0];
}
%%
int main ()
{
int ret = yylex();
printf("<[<]>[.>]\n");
return ret;
}

1771
bash/bff/text2bf.lex.c Normal file

File diff suppressed because it is too large Load Diff

40
bash/bff/text2bf.lex.l Normal file
View File

@ -0,0 +1,40 @@
/*
text to brainfuck converter
-- saves any input text inside the brainfuck registers and prints it
all out.
2004-07-22 - BeF <bef@erlangen.ccc.de>
compile hint:
lex -o text2bf.lex.c text2bf.lex.l
cc -pipe -O2 text2bf.lex.c -o text2bf -ll
*/
%{
int prevchar = 0;
%}
%%
(.|\n) {
printf("<[->+>+<<]>>[-<<+>>]<");
if (prevchar < yytext[0])
while (yytext[0]-prevchar++)
putchar('+');
else
while (yytext[0]-prevchar--)
putchar('-');
putchar('>');
prevchar = yytext[0];
}
%%
int main ()
{
int ret = yylex();
printf("<[<]>[.>]\n");
return ret;
}

15
bash/cpu/cpu.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# cpu usage
a=`cat /proc/stat|grep cpu|head -n1|sed -r 's/[0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+/Z&Z/'|cut -dZ -f2`
sleep 1
b=`cat /proc/stat|grep cpu|head -n1|sed -r 's/[0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+/Z&Z/'|cut -dZ -f2`
sum=0
for i in `seq 3`; do
s1="`echo $a|cut -d" " -f$i`"
s2="`echo $b|cut -d" " -f$i`"
sum=$sum+$s2-$s1
done
echo $sum|bc

5
bash/ftp/ipftp.txt Normal file
View File

@ -0,0 +1,5 @@
open ftp.narod.ru
mkdir ifconfig
cd ifconfig
send ifconfig-backbone.txt
quit

0
bash/getopt/getopt_ex.sh Executable file
View File

41
bash/gprs/wvdial/beeline1 Normal file
View File

@ -0,0 +1,41 @@
[Dialer defaults]
# Lines begining with # are comments.
# wvdial will look for this file at /etc/wvdial.conf or /home/LoginName/.wvdial.rc
# Redhat/Fedora have an Internet Connection Wizard in the popup menus
# ICW will write a two part /etc/wvdial.conf supporting multiple modem usage.
Modem = /home/kolan/.mobile_modem
Baud = 460000
Init1 = ATZ
Init2 = AT+CGDCONT=1,"IP","internet.beeline.ru"
# ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
# Lack of dialtone acquisition can be due to low line voltage,
# a common problem in Italy.
# Try inserting a "dial without waiting": X3
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +FCLASS=0
# In case of connection instabilities, specify a lower frequency:
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +MS=34
# ISDN = 0
# Modem Type = Analog Modem
# Phone = *99***1#
Phone = 0679
# if going through a switch board, a perhaps necessary pause can produced with a comma:
# Phone = 1,Dialout_phone_number
Username = beeline
# if Internet Provider is MSN.net, use under Linux: MSN/LoginName
Password = beeline
# the following lines is NEEDED only by slmodemd
Carrier check = no
# Kinternet appears to add it automatically.
## If CONNECT is achieved but browsing fails, try activating the following line
Auto DNS = yes
## To make a logfile wvdial.out
wvdial 2>&1 | tee wvdial.out
# # For some Internet providers, the following line is necessary
Stupid Mode = yes
## for other wvdial options, do "man wvdial" or see the documentation in
## /usr/share/doc/wvdial/
## End wvdial.conf

41
bash/gprs/wvdial/megafon1 Normal file
View File

@ -0,0 +1,41 @@
[Dialer defaults]
# Lines begining with # are comments.
# wvdial will look for this file at /etc/wvdial.conf or /home/LoginName/.wvdial.rc
# Redhat/Fedora have an Internet Connection Wizard in the popup menus
# ICW will write a two part /etc/wvdial.conf supporting multiple modem usage.
Modem = /home/kolan/.mobile_modem
Baud = 64000
Init1 = ATZ
#Init2 = AT+CGDCONT=1,"IP","internet"
# ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
# Lack of dialtone acquisition can be due to low line voltage,
# a common problem in Italy.
# Try inserting a "dial without waiting": X3
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +FCLASS=0
# In case of connection instabilities, specify a lower frequency:
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +MS=34
# ISDN = 0
# Modem Type = Analog Modem
#Phone = *99#
Phone = *99***1#
# if going through a switch board, a perhaps necessary pause can produced with a comma:
# Phone = 1,Dialout_phone_number
Username = gdata
# if Internet Provider is MSN.net, use under Linux: MSN/LoginName
Password = gdata
# the following lines is NEEDED only by slmodemd
Carrier check = no
# Kinternet appears to add it automatically.
## If CONNECT is achieved but browsing fails, try activating the following line
Auto DNS = yes
## To make a logfile wvdial.out
wvdial 2>&1 | tee wvdial.out
# # For some Internet providers, the following line is necessary
Stupid Mode = yes
## for other wvdial options, do "man wvdial" or see the documentation in
## /usr/share/doc/wvdial/
## End wvdial.conf

41
bash/gprs/wvdial/megafon2 Normal file
View File

@ -0,0 +1,41 @@
[Dialer defaults]
# Lines begining with # are comments.
# wvdial will look for this file at /etc/wvdial.conf or /home/LoginName/.wvdial.rc
# Redhat/Fedora have an Internet Connection Wizard in the popup menus
# ICW will write a two part /etc/wvdial.conf supporting multiple modem usage.
Modem = /home/kolan/.mobile_modem
Baud = 115200
Init1 = ATZ
#Init2 = AT+CGDCONT=1,"IP","internet"
# ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
# Lack of dialtone acquisition can be due to low line voltage,
# a common problem in Italy.
# Try inserting a "dial without waiting": X3
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +FCLASS=0
# In case of connection instabilities, specify a lower frequency:
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +MS=34
# ISDN = 0
# Modem Type = Analog Modem
#Phone = *99#
Phone = *99***1#
# if going through a switch board, a perhaps necessary pause can produced with a comma:
# Phone = 1,Dialout_phone_number
Username = gdata
# if Internet Provider is MSN.net, use under Linux: MSN/LoginName
Password = gdata
# the following lines is NEEDED only by slmodemd
Carrier check = no
# Kinternet appears to add it automatically.
## If CONNECT is achieved but browsing fails, try activating the following line
Auto DNS = yes
## To make a logfile wvdial.out
wvdial 2>&1 | tee wvdial.out
# # For some Internet providers, the following line is necessary
Stupid Mode = yes
## for other wvdial options, do "man wvdial" or see the documentation in
## /usr/share/doc/wvdial/
## End wvdial.conf

41
bash/gprs/wvdial/megafon3 Normal file
View File

@ -0,0 +1,41 @@
[Dialer defaults]
# Lines begining with # are comments.
# wvdial will look for this file at /etc/wvdial.conf or /home/LoginName/.wvdial.rc
# Redhat/Fedora have an Internet Connection Wizard in the popup menus
# ICW will write a two part /etc/wvdial.conf supporting multiple modem usage.
Modem = /home/kolan/.mobile_modem
Baud = 230400
Init1 = ATZ
#Init2 = AT+CGDCONT=1,"IP","internet"
# ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
# Lack of dialtone acquisition can be due to low line voltage,
# a common problem in Italy.
# Try inserting a "dial without waiting": X3
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +FCLASS=0
# In case of connection instabilities, specify a lower frequency:
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +MS=34
# ISDN = 0
# Modem Type = Analog Modem
#Phone = *99#
Phone = *99***1#
# if going through a switch board, a perhaps necessary pause can produced with a comma:
# Phone = 1,Dialout_phone_number
Username = gdata
# if Internet Provider is MSN.net, use under Linux: MSN/LoginName
Password = gdata
# the following lines is NEEDED only by slmodemd
Carrier check = no
# Kinternet appears to add it automatically.
## If CONNECT is achieved but browsing fails, try activating the following line
Auto DNS = yes
## To make a logfile wvdial.out
wvdial 2>&1 | tee wvdial.out
# # For some Internet providers, the following line is necessary
Stupid Mode = yes
## for other wvdial options, do "man wvdial" or see the documentation in
## /usr/share/doc/wvdial/
## End wvdial.conf

41
bash/gprs/wvdial/megafon4 Normal file
View File

@ -0,0 +1,41 @@
[Dialer defaults]
# Lines begining with # are comments.
# wvdial will look for this file at /etc/wvdial.conf or /home/LoginName/.wvdial.rc
# Redhat/Fedora have an Internet Connection Wizard in the popup menus
# ICW will write a two part /etc/wvdial.conf supporting multiple modem usage.
Modem = /home/kolan/.mobile_modem
Baud =460800
Init1 = ATZ
#Init2 = AT+CGDCONT=1,"IP","internet"
# ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
# Lack of dialtone acquisition can be due to low line voltage,
# a common problem in Italy.
# Try inserting a "dial without waiting": X3
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +FCLASS=0
# In case of connection instabilities, specify a lower frequency:
# Init2 = ATQ0 V1 E1 S0=0 X3 &C1 &D2 +MS=34
# ISDN = 0
# Modem Type = Analog Modem
#Phone = *99#
Phone = *99***1#
# if going through a switch board, a perhaps necessary pause can produced with a comma:
# Phone = 1,Dialout_phone_number
Username = gdata
# if Internet Provider is MSN.net, use under Linux: MSN/LoginName
Password = gdata
# the following lines is NEEDED only by slmodemd
Carrier check = no
# Kinternet appears to add it automatically.
## If CONNECT is achieved but browsing fails, try activating the following line
Auto DNS = yes
## To make a logfile wvdial.out
wvdial 2>&1 | tee wvdial.out
# # For some Internet providers, the following line is necessary
Stupid Mode = yes
## for other wvdial options, do "man wvdial" or see the documentation in
## /usr/share/doc/wvdial/
## End wvdial.conf

7
bash/trap/trap.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
trap 'echo bye ; exit 0' INT
while [[ "" == "" ]]; do
echo aa
done

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<software>
<settings>
<setting name="local directory" type="string">/home/username/</setting>
</settings>
</software>

BIN
cpp/boost/yAx/.ccc.swp Normal file

Binary file not shown.

22
cpp/boost/yAx/aaa Normal file
View File

@ -0,0 +1,22 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/blas.hpp>
#include <boost/numeric/ublas/lu.hpp>
using namespace boost::numeric::ublas;
int main()
{
matrix<double> A(2,2);
A(0,0) = 4; A(0,1) = 3;
A(1,0) = 6; A(1,1) = 3;
std::cout<<"A="<<A<<std::endl;
lu_factorize(A);
std::cout<<"A="<<A<<std::endl;
triangular_matrix<double> L(A);
return 0;
}

22
cpp/boost/yAx/bbb Normal file
View File

@ -0,0 +1,22 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/blas.hpp>
#include <boost/numeric/ublas/lu.hpp>
using namespace boost::numeric::ublas;
int main()
{
matrix<double> A(2,2);
A(0,0) = 4; A(0,1) = 3;
A(1,0) = 6; A(1,1) = 3;
std::cout<<"A="<<A<<std::endl;
lu_factorize(A);
std::cout<<"A="<<A<<std::endl;
triangular_matrix<double> L(A);
return 0;
}

22
cpp/boost/yAx/ccc Normal file
View File

@ -0,0 +1,22 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/blas.hpp>
#include <boost/numeric/ublas/lu.hpp>
using namespace boost::numeric::ublas;
int main()
{
matrix<double> A(2,2);
A(0,0) = 4; A(0,1) = 3;
A(1,0) = 6; A(1,1) = 3;
std::cout<<"A="<<A<<std::endl;
lu_factorize(A);
std::cout<<"A="<<A<<std::endl;
triangular_matrix<double> L(A);
return 0;
}

BIN
cpp/boost/yAx/lu Executable file

Binary file not shown.

22
cpp/boost/yAx/lu.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/blas.hpp>
#include <boost/numeric/ublas/lu.hpp>
using namespace boost::numeric::ublas;
int main()
{
matrix<double> A(2,2);
A(0,0) = 4; A(0,1) = 3;
A(1,0) = 6; A(1,1) = 3;
std::cout<<"A="<<A<<std::endl;
lu_factorize(A);
std::cout<<"A="<<A<<std::endl;
triangular_matrix<double> L(A);
return 0;
}

BIN
cpp/boost/yAx/rnd Executable file

Binary file not shown.

30
cpp/boost/yAx/rnd.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <boost/random.hpp>
#include <ctime>
using namespace boost;
double SampleNormal (double mean, double sigma)
{
// выбор генератора случайных чисел
mt19937 rng;
// инициализация генератора числом секунд с 1970 года
rng.seed(static_cast<unsigned> (std::time(0)));
// выбор нужного распределения
normal_distribution<double> norm_dist(mean, sigma);
// привязка генератора к распределению
variate_generator<mt19937&, normal_distribution<double> > normal_sampler(rng, norm_dist);
// пример работы
for(int i=0; i<10; i++)
std::cout<<normal_sampler()<<std::endl;
return normal_sampler();
}
int main()
{
SampleNormal(5,1);
return 0;
}

BIN
cpp/boost/yAx/yAx Executable file

Binary file not shown.

19
cpp/boost/yAx/yAx.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;
int main() {
vector<double> x(2);
x(0) = 1; x(1) = 2;
matrix<double> A(2,2);
A(0,0) = 0; A(0,1) = 1;
A(1,0) = 2; A(1,1) = 3;
vector<double> y = prod(A, x);
std::cout << "y=" << y << std::endl;
std::cout << "A=" << A << std::endl;
return 0;
}

BIN
cpp/const_ul/cont_ul Executable file

Binary file not shown.

19
cpp/const_ul/cont_ul.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <iostream>
#include <stdio.h>
using namespace std;
void test0()
{
static const unsigned long a = 4026531840;
unsigned long b = 4026531840;
static const unsigned long c = 4026531840UL;
printf("a=%u b=%u c=%u\n", a, b, c);
}
int main()
{
test0();
return 0;
}

46
cpp/recpath/recpath.cpp Normal file
View File

@ -0,0 +1,46 @@
#include <iostream>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
using namespace std;
using namespace boost;
using namespace boost::filesystem;
static void Process_Files( const path &Path, bool recurse )
{
cout << "Processing folder " << Path.native_file_string() << "\n";
directory_iterator end_itr; // default construction yields past-the-end
for(
directory_iterator itr( Path );
itr != end_itr;
++itr
)
{
if( recurse && is_directory( *itr ) )
{
// Погружаемся на 1 уровень вниз по дереву каталогов
path Deeper( *itr );
Process_Files( Deeper,recurse );
continue;
}
// Файл, путь к которому содержится в filename, можно обрабатывать.
string filename = itr->native_file_string();
cout << filename << "\n";
}
return;
}
int main( int argc, char* argv[] )
{
bool recurse=true; // обходить ли каталоги
Process_Files( current_path(), recurse );
return 0;
}

BIN
cpp/static_map/static_map Executable file

Binary file not shown.

View File

@ -0,0 +1,25 @@
#include <iostream>
#include <map>
struct pair
{
std::string offs;
std::string scal;
pair(const std::string& o, const std::string& s)
{
offs = o;
scal = s;
}
};
void f()
{
std::map<std::string,pair> old_ch_names;
}
int main()
{
f();
return 0;
}