Skip to content

Instantly share code, notes, and snippets.

View Source.hs
main = do
firstName <- getLine
print firstName
-- Functors apply a function that takes a value and returns a value to a
-- wrapped value.
class Functor c where
fmap :: (a -> b) -> c a -> c b
($) :: c a -> (a -> b) -> c b
@nishanths
nishanths / gist:bf63bab71274d0b0d81fb677f05d4654
Created Aug 23, 2020
A bookmarklet to edit a Svbtle post from the published post's page.
View gist:bf63bab71274d0b0d81fb677f05d4654
javascript:(() => { window.open("https://svbtle.com" + window.location.pathname + "/edit", "_blank") })()
View tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"strict": true,
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": [
@nishanths
nishanths / just-files-server.go
Created Mar 23, 2020
Regular Go HTTP file server except that it disallows Readdir
View just-files-server.go
package main
import (
"log"
"net/http"
"os"
)
type justFilesFilesystem struct {
fs http.FileSystem
View ticker.go
// Command ticker runs a command at the specified frequency.
// The frequency can be shorter than the time that the command will take to execute
// (a new goroutine is spawned for each invocation). Writes the command's stdout
// and stderr to the process's stdout and stderr. The exit code is ignored.
package main
import (
"flag"
"log"
"os"
View afraiddns.sh
#!/usr/bin/env bash
set -e
# Updates the freedns.afraid.org DNS record for a domain, if the domain's
# resolved IP does not match the external IP of the machine running this program.
usage() {
echo "usage: afraiddns.sh <domain>"
exit 1
}
@nishanths
nishanths / init.vim
Created Nov 27, 2019
$HOME/.vim/init.vim
View init.vim
set nocompatible " be iMproved, required
filetype off " required
" Plugins list
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
Plug 'HerringtonDarkholme/yats.vim' " REQUIRED: Add a syntax file. YATS is the best
Plug 'mhartington/nvim-typescript', {'do': './install.sh'}
Plug 'tpope/vim-jdaddy' "JSON format: gqaj
" For async completion?
View nvim --version
$ nvim --version
NVIM v0.3.5
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190429-2015-1h8cwza/neovim-0.3.5/build/config -I/tmp/neovim-20190429-2015-1h8cwza/neovim-0.3.5/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20190429-2015-1h8cwza/neovim-0.3.5/build/src/nvim/auto -I/tmp/neovim-20190429-2015-1h8cwza/neovim-0.3.5/build/include
Compiled by brew@Mojave.local
Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"
View iterator.go
type Iterator interface {
// Next returns the next value and true, or (0, false) if there
// are no more values.
// (If Go supported generics, the value type would be a type parameter
// instead of hard-coded to int since the algorithm should work fine for
// any comparable type... Keep it simple for the interview and hardcode
// the value type to int.)
Next() (int, bool)
}
View prs.diff
diff --git a/main.go b/main.go
index 3db4db3..bb17d0d 100644
--- a/main.go
+++ b/main.go
@@ -42,7 +42,9 @@ func main() {
displayItems(items)
}
-func endpoint(user string) string {
+// endpoint returns the URL for fetching the given user's pull requests.