This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* trim: удаляет завершающие пробелы, табуляции и новые строки */ | |
int trim(char s[]) | |
{ | |
int n; | |
for (n = strlen(s) - 1; n >= 0; --n) | |
{ | |
if ((s[n] != ' ') && (s[n] != '\t') && (s[n] != '\n')) | |
break; // выходим из цикла, встретив печатаемый символ | |
} | |
s[n+1] = '\0'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PrintPositives(int array[], int arraySize) | |
{ | |
int i; | |
for (i = 0; i < arraySize; i++) | |
{ | |
if (array[i] < 0) /* пропуск отрицательных элементов */ | |
continue; | |
printf("%d ", array[i]); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void Print(int number) | |
{ | |
printf("%d", number); | |
} | |
void Print(double number) | |
{ | |
printf("%.15f", number); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IntStack | |
{ | |
public: | |
void Push(int value); | |
int Pop(); | |
bool isEmpty() const; | |
private: | |
// здесь располагаются данные | |
// необходимые для реализации стека целых чисел |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Plane | |
{ | |
public: | |
void TakeOff(); | |
void Fly(); | |
void Land(); | |
private: | |
double m_fuel; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Полиморфизм - классы-потомки могут изменять реализацию метода класса-предка, сохраняя его интерфейс | |
class Shape | |
{ | |
public: | |
virtual ~Shape() | |
{ | |
} | |
virtual double GetArea() const = 0; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// пример объявления класса | |
class Date | |
{ | |
public: | |
void Next(); | |
void Print() const; | |
private: | |
int year, month, day; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple No-ip.com Dynamic DNS Updater | |
# | |
# By Nathan Giesbrecht (http://nathangiesbrecht.com) | |
# | |
# 1) Install binary as described in no-ip.com's source file (assuming results in /usr/local/bin) | |
# 2) Run sudo /usr/local/bin/noip2 -C to generate configuration file | |
# 3) Copy this file noip2.service to /etc/systemd/system/ | |
# 4) Execute `sudo systemctl enable noip2` | |
# 5) Execute `sudo systemctl start noip2` | |
# |
OlderNewer