Skip to content

Instantly share code, notes, and snippets.

View montreal91's full-sized avatar
💭
Set your status

Alexander Nefedov montreal91

💭
Set your status
  • Belgrade, Serbia
View GitHub Profile
@montreal91
montreal91 / lab 5.6.sql
Created November 26, 2015 19:33
lab 5.6.sql
SELECT n_tariff * (
SELECT count(n_client)
FROM client
) * (
SELECT sum(n_difference_hot)
FROM computation
WHERE to_char(d_computation, 'MM.YYYY') = '09.2008'
)
FROM tariff
WHERE d_tariff = (
@montreal91
montreal91 / gist:089e9b1dc76122cd0318
Created November 14, 2015 16:23
massive-case.cc
std::string toString(sf::Keyboard::Key key)
{
#define BOOK_KEYTOSTRING_CASE(KEY) case sf::Keyboard::KEY: return #KEY;
switch (key)
{
BOOK_KEYTOSTRING_CASE(Unknown)
BOOK_KEYTOSTRING_CASE(A)
BOOK_KEYTOSTRING_CASE(B)
BOOK_KEYTOSTRING_CASE(C)
@montreal91
montreal91 / wtf.cpp
Created November 11, 2015 17:56
wtf-case
foo
SELECT n_sum, d_pay, n_client
FROM payment
WHERE n_client = (
SELECT n_client
FROM computation
WHERE n_debt = (
SELECT max(n_debt)
FROM computation
)
@montreal91
montreal91 / calendar.c
Created October 12, 2015 19:54
Calendar with C
#include <stdio.h>
int get_days_in_month( int month, int year ) {
if ( month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ) {
return 31;
} else if ( month == 4 || month == 6 || month == 9 || month == 11 ) {
return 30;
} else if ( month == 2 && year % 4 == 0 ) {
return 29;
@montreal91
montreal91 / gist:61281fc9204168a22770
Created October 9, 2015 06:52
esoteric quadratic C++
bool solveQuadratic( const float a, const float b, const float c, float& x0, float& x1 ) {
float discr = b * b - 4 * a * c;
if ( discr < 0 ) {
return false;
} else if ( discr == 0 ) {
x0 = -0.5 * b / a;
x1 = x0;
} else {
float q = ( b > 0 ) ?
-0.5 * ( b + sqrt( discr ) ) :
@montreal91
montreal91 / glt.py
Last active October 11, 2015 06:33
values
def GetLuckyTriple( self ):
"""
Метод, который ищет отрезок, содержащий минимум функции.
"""
start = -1
end = self._accuracy * 2 - 1
for i in range( 10000 ):
middle = ( start + end ) / 2
if self._IsTripleLucky( start, end, middle ):
OldMatrix OldMatrix::operator+ (OldMatrix &B)
{
OldMatrix C(Row, Col);
if ((Row == B.Row) && (Col == B.Col))
for (int i = 0; i < Row; i++)
{
for (int j = 0; j < Col; j++)
C[i][j] = M[i][j] + B[i][j];
}
return C;
@montreal91
montreal91 / main.cpp
Created September 25, 2015 16:35
matrix hell
mat3 = mat1 * mat2 + mat3; // correct
mat3 = mat1 * mat2 + mat3 * mat1; // produces next error
main.cpp: In function ‘void TestVectorMatrix()’:
main.cpp:28:21: error: no match for ‘operator*’ (operand types are ‘Matrix’ and ‘Matrix’)
mat3 = mat1 * ( mat2 + mat3 ) * mat2;
^
main.cpp:28:21: note: candidate is:
In file included from main.cpp:1:0:
matrix.h:28:12: note: Matrix Matrix::operator*(Matrix&)
@montreal91
montreal91 / glxinfo_out2.sh
Created August 31, 2015 18:55
glxinfo_out2
foo