Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@mislav
mislav / fuzzy.coffee
Created January 20, 2015 01:47
Fuzzy scoring algorithm adopted from Selecta as used on GitHub.com
# Get the shortest match (least distance between start and end index) for all
# the query characters in the given text.
#
# Returns an array in format [firstIndex, matchLength, [matchIndexes]]
shortestMatch = (text, queryChars) ->
starts = allIndexesOf(text, queryChars[0])
return if starts.length is 0
return [starts[0], 1, []] if queryChars.length is 1
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@mislav
mislav / survey
Created November 1, 2009 11:27 — forked from radar/survey.md
What did you do to get good at Rails?
Read source code, wrote plugins
Who taught you what you know?
Josh Susser! (about ActiveRecord)
Do you have any fond (or not so fond) memories of your learning experiences?
@mislav
mislav / windows-on-mac.md
Last active February 21, 2024 23:38
Install Windows 11 in a virtual machine on macOS with an M1 CPU

Based on https://docs.getutm.app/guides/windows/

  1. You will need:
    • A Windows 10 or Windows 11 license key;
    • UTM for Mac - the App Store version is offered as a way to support the developers, since it's paid, but has the same features as the free build.
  2. Obtain scripts that bootstrap an arm64 Windows 11 22H2 (I've chosen Windows Home edition and not Pro);
  3. brew install aria2 cabextract wimlib cdrtools minacle/chntpw/chntpw;
  4. cd into the directory extracted in step 1 and bash uup_download_macos.sh - this will produce an ISO;
  5. In the UTM app, create a new “Virtualize” machine and mount the ISO file from the previous step;
  6. Check “Install drivers and SPICE tools”;
@mislav
mislav / netflix.sh
Last active February 21, 2024 16:56
Watch Netflix as if you were in the US by proxying DNS through a DigitalOcean instance.
#!/bin/bash
set -e
droplet=netflix
interface=Wi-Fi
us_regions=( nyc1 nyc2 nyc3 )
random_region() {
echo ${us_regions[RANDOM % ${#us_regions[@]}]}
}
@mislav
mislav / bookmarklet.md
Last active February 13, 2024 16:18
cooked.wiki bookmarklet
javascript:window.location="https://cooked.wiki/"+window.location
@mislav
mislav / aprompt.png
Last active February 11, 2024 06:40
My zsh prompt. No oh-my-zsh needed
aprompt.png
@mislav
mislav / hub-api-comments.sh
Last active January 24, 2024 23:38
hub api example of how to fetch all comments over GraphQL
comments() {
local issue="${1?}"
shift 1
paginate hub api --cache 3600 graphql -F issue="$issue" "$@" -f query='
query ($owner: String = "{owner}", $repo: String = "{repo}", $issue: Int!, $per_page: Int = 30, $after: String) {
repository(owner: $owner, name: $repo) {
issueOrPullRequest(number: $issue) {
... on Issue {
comments(first: $per_page, after: $after) {
...Comments
@mislav
mislav / config.json
Last active January 18, 2024 10:48
Experiment in using GitHub CLI to authenticate fetching docker images from GitHub Package Registry
// ~/docker/config.json
{
"credsStore": "desktop",
"credHelpers": {
"docker.pkg.github.com": "gh",
"ghcr.io": "gh"
}
}