Skip to content

Instantly share code, notes, and snippets.

View be9's full-sized avatar

Oleg Dashevskii be9

View GitHub Profile
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="GPS TrackMaker" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata>
<link href="http://www.gpslib.ru">
<text>GPSLib tracks collection</text>
</link>
<time>2014-11-24T10:29:38+03:00Z</time>
<bounds minlat="45.011369" minlon="41.946345" maxlat="45.015844" maxlon="41.954083" />
</metadata>
<trk>
@be9
be9 / circle.c
Created September 10, 2014 06:58
#include <stdio.h>
#include "circle.h"
#include "new.h"
static void *Circle_ctor(void *_self, va_list *app) {
struct Circle *self = ((const struct Class *)Point)->ctor(_self, app);
self->rad = va_arg(*app, int);
return self;
}
if ENV['INSTRUMENT_CACHE_KEYS']
class CacheKeyInstrumenter
include Singleton
def hit(payload)
record :hits, payload
end
def miss(payload)
  1. Стандартные контейнеры C++.
  2. Алгоритмы в стандартной библиотеке C++ (#include ).
  3. Конструктор копирования. Перегрузка оператора присваивания. Ключевое слово explicit.
  4. Перегрузка операторов в C++.
  5. Принцип RAII. Умные указатели в C++. Мотивация и реализация.
  6. Паттерн Singleton («одиночка»). Варианты его реализации в C++.
  7. Принцип COW.
  8. RTTI в C++.
  9. Паттерны Singleton, Prototype и Builder.
  10. Паттерны Abstract Factory и Factory Method.
#include <vector>
#include <iostream>
using namespace std;
template <typename T>
class Initializer {
public:
Initializer(T &_array)
: array(_array) {}
@be9
be9 / -
Created February 20, 2014 12:55
ExifTool Version Number : 9.47
File Name : IMG_0021.JPG
Directory : /Volumes/RedStore/Tanya/fotos/14_02_20_start_d20
File Size : 2.5 MB
File Modification Date/Time : 2014:02:20 17:23:02+07:00
File Access Date/Time : 2014:02:20 17:23:02+07:00
File Inode Change Date/Time : 2014:02:20 17:23:02+07:00
File Permissions : rwxr--r--
File Type : JPEG
MIME Type : image/jpeg
@be9
be9 / gist:7131763
Last active December 26, 2015 09:49
1. Find the row (i-th) with max total width
2. Sort the images, so that widest goes first and narrowest last.
3. Loop for all images in i-th starting from widest (image A):
4. For each other row (j-th):
5. Try to move image A to j-th row. That is, if TotalSize[j] + width[A] < TotalSize[i], move and stop. Improvement done.
dp_development=# \d transport_stations
Таблица "public.transport_stations"
Колонка | Тип | Модификаторы
------------+-----------------------------+-----------------------------------------------------------------
id | integer | NOT NULL DEFAULT nextval('transport_stations_id_seq'::regclass)
name | character varying(255) |
lng | double precision |
lat | double precision |
code | character varying(255) |
details | character varying(255) |
@be9
be9 / paginate.rb
Created September 5, 2013 04:18
kaminari + JSON API pagination helper
def paginate(scope, default_per_page = 20)
collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i)
current, total, per_page = collection.current_page, collection.num_pages, collection.limit_value
return [{
pagination: {
current: current,
previous: (current > 1 ? (current - 1) : nil),
next: (current == total ? nil : (current + 1)),
records = redis.zrange(global_key, 0, @options[:batch] - 1).map { |r| JSON.parse(r) }
return false if records.empty?
per_member_count = Hash.new { |h,k| h[k] = 0 }
columns = %w(action comment_id created_at member_id item_id receiver_id store_id text)
PostgresCopy.new(Activity.table_name, columns).go do |pc|
records.each { |r|