我已经为我所有的点文件设置了一个github仓库:https://github.com/jaymody/dotfiles
这个想法是,如果我要重置机器(mac,尽管我有计划使其适应linux),我基本上可以下载存储库,运行脚本并安装所有我的首选项/设置/应用程序。 / p>
它工作正常,除了我意识到为了获取需要git
在我的机器上已经安装git clone
的存储库才能git archive
。我不喜欢必须安装git的想法,因为回购的全部目的是处理所有这些东西(它通过自制软件安装git)。
我知道您可以wget
的存储库来创建.zip文件,因此一种简单的解决方案是将.zip文件存储在存储库中并使用curl
或tags
得到邮编。尽管我觉得必须有一个比这更好的解决方案。我知道您也可以为echo "export DOTFILES_ROOT=path/to/where/you/want/to/save/this/repo/" >> ~/.localrc
source ~/.localrc
git clone https://github.com/jaymody/dotfiles.git $DOTFILES_ROOT
cd $DOTFILES_ROOT
./bootstrap
创建档案,但是存在的问题是,我始终希望为存储库的最新提交添加标签。
echo "export DOTFILES_ROOT=path/to/where/you/want/to/save/this/repo/" >> ~/.localrc
source ~/.localrc
##### DOWNLOAD GITHUB REPO WITHOUT USING GIT HERE #####
cd $DOTFILES_ROOT
./bootstrap
#include <iostream>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <conio.h>
#include <fstream>
const int N=30; //max students
const char students[]="students.dat";
struct student
{
std::string fnom;
std::string name;
char sex;
int age;
int ocenki[4];
double srusp;
};
int n;
std::fstream fp;
void menu();
void crstudent(struct student stud[]);
void chkinfo(struct student stud[]);
void addstudent();
void back();
void main()
{
menu();
}
void menu()
{
struct student stud[N];
int choice;
do
{
do
{
std::cout << "---------------//MENU//---------------\n\n";
std::cout << "Choose one of the following options: \n\n";
std::cout<<"1.Add a new student.\n"
<<"2.Check info about a student.\n"
<<"3..\n"
<<"4..\n"
<<"5.Exit program.\n\n";
std::cout << "Input: ";
std::cin>>choice;
system("CLS");
}
while(choice<1||choice>5);
switch(choice)
{
case 1:
{
int ch1;
do
{
std::cout<<"1. Create a group of students.\n"
<<"2. Add a new student.\n"
<<"3. Back.\n";
std::cin>>ch1;
system("CLS");
}
while(ch1<1||ch1>3);
switch(ch1)
{
case 1:
crstudent(stud);
break;
case 2:
addstudent();
break;
case 3:
continue;
break;
}
break;
}
case 2:
chkinfo(stud);
break;
case 3:
break;
case 4:
break;
case 5:
exit(0);
break;
default:
std::cout<<"Wrong input.\n"<<"Try again.\n";
}
}
while (choice !=5);
}
void crstudent(struct student stud[])
{
fp.open("students.dat",std::ios::out);
if(!fp)
{
std::cout<<std::endl<<"Error creating the file!";
exit(1);
}
std::cout<<"Input the number of students you wish to add: ";
std::cin>>n;
for(unsigned int i=0; i<n; i++)
{
fflush(stdin);
std::cout<<"Input student "<<i+1<<" faculty number: ";
std::cin.ignore();
std::getline(std::cin,stud[i].fnom);
std::cout<<"Input student's name: ";
std::getline(std::cin,stud[i].name);
std::cout<<"Input student's age: ";
std::cin>>stud[i].age;
std::cout<<"Input student's sex - M or F: ";
std::cin >> stud[i].sex;
stud[i].sex=std::toupper(stud[i].sex);//Converting lowercase to uppercase
stud[i].srusp=0;
std::cout<<"Input student's marks: \n";
for(int k=0; k<4; k++)
{
std::cout<<"Input mark number "<<k+1<<": ";
std::cin>>stud[i].ocenki[k];
stud[i].srusp+=stud[i].ocenki[k];
}
stud[i].srusp=stud[i].srusp/4.00;
std::cout<<std::endl;
}
fp.write((char*)stud,n*sizeof(student));
fp.close();
system("CLS");
}
void chkinfo(struct student stud[])
{
std::streamoff pos;
student s;
fp.open("students.dat", std::ios::in);
if (!fp)
{
std::cout << std::endl << "File does not exist!";
exit(1);
}
fp.seekg(0L, std::ios::end);
pos = fp.tellg();
fp.close();
fp.open("students.dat", std::ios::in);
fp.seekg(0);
for (unsigned int i = 0; i < (pos / sizeof(student)); i++)
{
fp.read((char*)&s, sizeof(student));
stud[i] = s;
std::cout << std::endl << "Faculty number: " << stud[i].fnom; //The error occurs here!
std::cout << std::endl << "Name: " << stud[i].name;
std::cout << std::endl << "Age: " << stud[i].age;
std::cout << std::endl << "Sex: " << stud[i].sex;
std::cout << std::endl << "Average result is: " << stud[i].srusp;
std::cout << std::endl;
}
fp.close();
back();
}
void addstudent()
{
student ss;
std::streamoff pos;
fp.open("students.dat",std::ios::in);
if(!fp)
{
std::cout<<std::endl<<"File does not exist!";
exit(1);
}
fp.seekg(0L,std::ios::end);
pos=fp.tellg();
fp.close();
fp.open("students.dat",std::ios::out|std::ios::app);
if(!fp)
{
std::cout<<std::endl<<"File does not exist!";
exit(1);
}
std::cout<<"Input student "<<pos/(sizeof(student))+1<<" faculty number: ";
std::cin.ignore();
std::getline(std::cin,ss.fnom);
std::cout<<"Input student's name: ";
std::getline(std::cin,ss.name);
std::cout<<"Input student's age: ";
std::cin>>ss.age;
std::cout<<"Input student's sex: ";
std::cin>>ss.sex;
ss.srusp=0;
std::cout<<"Input student's marks: \n";
for(int k=0; k<4; k++)
{
std::cout<<"Input mark number "<<k+1<<": ";
std::cin>>ss.ocenki[k];
ss.srusp+=ss.ocenki[k];
}
ss.srusp=ss.srusp/4.00;
std::cout<<std::endl;
fp.write((char*)&ss,n*sizeof(student));
fp.close();
system("CLS");
}
void back()
{
std::cout << "\nPress F to go back or Q to quit: ";
char back;
std::cin >> back;
if (back == 'F' || back == 'f') { system("CLS"); menu(); }
else if (back == 'Q' || back == 'q') exit(0);
}
注意:显然,这是矫kill过正,我几乎永远不需要使用此功能,但是如果我过度自动化某些东西,不妨全力以赴。
答案 0 :(得分:3)
使用此文件将其下载为zip文件。
wget https://github.com/jaymody/dotfiles/archive/master.zip
unzip master.zip