Skip to content

Instantly share code, notes, and snippets.

View valencik's full-sized avatar
🍍

Andrew Valencik valencik

🍍
View GitHub Profile
@valencik
valencik / thorium.rb
Created April 4, 2014 01:55
Dishonourable Ruby Warrior Code
class Player
@health = 20
@wall_reached = false
def play_turn(warrior)
@if_pivot = true
if (!@if_pivot)
warrior.pivot!

Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question: what is your most productive shortcut?

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char * append (char *field, size_t *size, size_t *len, char c);
static size_t get_field (char **field, size_t *size, FILE *file);
static char const * strip_field (char *field, size_t len);
static bool end_of_file = false;
@valencik
valencik / vimdeck-presentation
Created September 7, 2014 18:12
Vimdeck multiple lists issue.
$ls -l presentation/
total 16
-rw-r--r-- 1 andrew admin 153 7 Sep 14:58 script.vim
-rw-r--r-- 1 andrew admin 360 7 Sep 14:58 slide001.md
-----
$cat script.vim
set nonumber
set hidden
noremap <PageUp> :bp<CR>
@valencik
valencik / units-2.11-compile-error.log
Created September 21, 2014 17:42
Error compiling units-2.11 on Mac OS X
AndrewMBP:units-2.11 andrew$ ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
@valencik
valencik / README.md
Created September 25, 2015 22:21 — forked from anonymous/README.md
Quick Gist: The self replicating chrome extension
  • Download this gist as a zip and extract
  • Open chrome://extensions
  • Enable Developer mode
  • Click Load unpacked extension... and select the extracted folder
  • 💵 Profit 💵

Created by the SMU CS Society

# Previously Seen Queries
- can i cancel a refund
- how can i cancel an order
- cancel my account
- can i dropship using paypal
- paypal payments
- paypal providers
@valencik
valencik / aoc-2022-day1-gpt3.md
Created December 1, 2022 13:06
Getting GPT-3 (text-davinci-003) to solve Advent of Code day one in python
@valencik
valencik / gpt-parallel-requests-typelevel.md
Created December 2, 2022 01:16
Asking ChatGPT how to use Typelevel libraries for some parallel fetching.

I'm writing purely functional code in Scala, using the ecosystem of Typelevel libraries. Specifically I'm using cats-effect, fs2, and http4s.

I have a list of URLs, how do make parallel GET requests to them and write their bytes to disk?


Here is one way you can do it using the cats-effect, fs2, and http4s libraries in Scala:

Import the necessary libraries:

@valencik
valencik / cats-hierarchy.md
Created December 29, 2022 01:09
A very simplified view of the cats typeclass hierarchy building to IO

Cats

The Typelevel ecosystem of libraries for functional programming in Scala provides several fundamental type classes for representing the capabilities of different computations.

Functor

Effect: Transforming the value inside an effect by mapping over it

[📚 Functor docs][docs-functor]