Skip to content

Instantly share code, notes, and snippets.

View karptonite's full-sized avatar

Daniel Karp karptonite

View GitHub Profile

I have an interesting (to me) pagination related problem. I'm working on both the back end (a JSON API) and the front end (angular) of a comments system. Currently, the comments are page from oldest to newest, 20 per page, defaulting to the first page (oldest), with the API pages matching the pages we show to users.

We are switching to a front end with the following features: we show by default the x newest comments, with a "load previous" button to show y additional comments at a time. Additionally, you can deep link to a particular comment, which will mean showing x comments including x by default, with load y previous/next comments.

This is a private API for now, but may eventually become public. I'm trying to figure out how much of the new pagination behavior to handle in the API vs how much of it to handle in the client.

so, things I could put on the API or handle in the client include: passing perPage to the API or slicing up the data client side to handle the x / y per page requirements of the new s

@karptonite
karptonite / GeekDB_Fetcher_Factory.php
Last active March 9, 2017 03:12
Use case for parameters for container
<?php
class GeekDB_Fetcher_Factory
{
public function create( $type, $setupData = null )
{
switch ($type)
{
case 'direct':
return new GeekDB_Fetcher_Direct( $setupData );
break;
<ui-select
multiple
tagging="makeNonUserPlayer"
tagging-label="false"
ng-model="play.players"
force-options-down="true"
on-select="selectPlayerCallback($item)"
focus-on="AddPlayerFocus"
theme="bootstrap">
<ui-select-match hide-tags="true" placeholder="Search users or enter player name">
<?php
3
2 $start = microtime( true );
1
5 $script = 'roman-numerals.php';
1 require( $script );
2 for( $i = 1; $i <= 3000; $i++ )
3 {
4 toRoman( $i );
5 }
@karptonite
karptonite / gist:37dc7b0d0d355e8e3437
Created June 10, 2015 15:42
xhaskell test output
-- accumulate
Cases: 6 Tried: 6 Errors: 0 Failures: 0
-- allergies
Cases: 12 Tried: 12 Errors: 0 Failures: 0
-- anagram
Cases: 9 Tried: 9 Errors: 0 Failures: 0
-- atbash-cipher
Cases: 9 Tried: 9 Errors: 0 Failures: 0
-- bank-account
clicking on someone's feedback when browsing games should take you to their feedback page.
When browsing all items for sale by a particular user, the seller, and feeback columns are redundant.
The "Payments" column is confusing. I had no idea why it was there till I clicked it.
Clicking "Payments" shows payments accepted, but then the popup doesn't go away for me unless I click "payments" again. Clicking anywhere (or even mousing out, or waiting) should make it go away.
It is weird to have something called "filters" at the top, then most of the filters (condition, Currency, and ship locations) below. I clicked on filters, and thought that that the only way to filter was by subtype.
Pagers should go away (or be less visible) if there is only one page.
When I type someothing in the searchbox, and hit enter, I get "invalid action". http://aldie.geekdo.com/geekmarket.php?action=search&q=test
I see a "login" link despite the fact that I'm already logged in.
<?php
namespace Geek\Cache;
class CacheBuilder
{
private $cache;
private $memocache;
private $tagsetfactory;
public function __construct( Cache $cache, Cache $memocache, TagSetFactory $tagsetfactory, array $stack = null )
{
<?php
namespace Geek\Cache;
class CacheBuilder
{
private $cache;
private $memocache;
private $tagsetfactory;
public function __construct( Cache $cache, Cache $memocache, TagSetFactory $tagsetfactory, array $stack = null )
{
source ~/dotfiles/bundles.vim
set background=dark
" let g:solarized_visibility="low"
colorscheme solarized
" handled by vim-sleuth now?
set tabstop=3
set softtabstop=3
set shiftwidth=3