Skip to content

Instantly share code, notes, and snippets.

// Pagination as a function
static IQueryable<T> Paginate<T>(this IQueryable<T> query, int pageNumber, int pageSize) =>
query.Skip(pageSize*pageNumber).Take(pageSize);
// Usage
var paginatedQuery = originalQuery.Paginate(pageNumber, pageSize);
// Composition (fluent with extension methods)
var paginatedFilteredQuery = originalQuery.Where(predicate).Paginate(pageNumber, pageSize);
@Tharos
Tharos / gist:8680094dddc708f65c27
Created November 16, 2014 12:44
Query Objects with Lean Mapper (snippet)
<?php
/**
* Vykreslení přehledu produktů v e-shopu
*
* @var Filter $filter Filtr, který omezuje množinu produktů podle nastavení uživatele
* @var int|null $limit Počet produktů zobrazených na stránce
* @var VisualPaginatorHelper $visualPaginatorHelper Jednoduchý helper, který pomáhá inicialzovat Paginator (Nette)
* @var VisualPaginator $visualPaginator VisualPaginator (Nette)
* @var Template $template Šablona view
@wrighter
wrighter / download_bars.py
Last active October 4, 2024 21:50
A command line utility to download historical data from Interactive Brokers
#!/usr/bin/env python
import os
import sys
import argparse
import logging
from datetime import datetime, timedelta
from typing import List, Optional
from collections import defaultdict