public class Example {
private static final String FILE_NAME = "state.dat";
private int value;
public void setValue(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static void main(String[] args) {
Example obj = new Example();
try (InputStream in = new FileInputStream(FILE_NAME)) {
obj.setValue(in.read());
} catch (IOException exc) {
exc.printStackTrace();
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try (OutputStream out = new FileOutputStream(FILE_NAME)) {
out.write(obj.getValue());
} catch (IOException exc) {
exc.printStackTrace();
}
}));
}
}
class EmailAuthenticationBackend(ModelBackend):
def authenticate(self, request, email=None, password=None):
try:
user = User.objects.get(email=email)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
Разобраться и понять, что происходит на каждом этапе компиляции программ
В совершенстве овладеть такой вещью, как GNU ассемблер.
Самому написать компилятор для linux
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
...
</project>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_TOKENS 3
#define DELIMITER "\n"
int main(int argc, char* argv[]) {
char s[30] = "file2.py\n"
"file3.py\n\n" // Хоть одинарные, хоть двойные
"file.py\n";
char* tokens[MAX_TOKENS];
char* token = strtok(s, DELIMITER);
for (int i = 0; (token != NULL) && (i < MAX_TOKENS); i++) {
tokens[i] = token;
token = strtok(NULL, DELIMITER);
}
for (int i = 0; i < MAX_TOKENS; i++)
printf("%s\n", tokens[i]);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#define BUF_SIZE 128
int name_pc(char* buf) {
FILE *p = popen("hostname", "r");
if (p == NULL)
return 0;
int r = 1;
if (!fgets(buf, BUF_SIZE, p))
r = 0;
pclose(p);
return r;
}
int main(int argc, char* argv[]) {
char hostname[BUF_SIZE];
if (!name_pc(hostname)) {
fputs("Error!", stderr);
return EXIT_FAILURE;
}
printf("%s\n", hostname);
return EXIT_SUCCESS;
}