Skip to content

Instantly share code, notes, and snippets.

View srcrip's full-sized avatar
🔮
typescript is best script

Andrew Stewart srcrip

🔮
typescript is best script
View GitHub Profile
@srcrip
srcrip / init.el
Created November 6, 2018 23:03
Lightweight Helm Config for Emacs
(defun helm-or-evil-escape ()
"Escape from anything."
(interactive)
(cond ((minibuffer-window-active-p (minibuffer-window))
;; quit the minibuffer if open.
(abort-recursive-edit))
;; Run all escape hooks. If any returns non-nil, then stop there.
;; ((cl-find-if #'funcall doom-escape-hook))
;; don't abort macros
((or defining-kbd-macro executing-kbd-macro) nil)
@srcrip
srcrip / README.md
Last active November 19, 2018 22:29
Scripts for getting random wallpapers from unsplash.it, saving them, cycling them every hour, etc

Setup

This configuration assumes you put these scripts in ~/scripts/, and that this directory is in your $PATH variable. You can change this to your desired scripts directory instead. Just be sure to change cycle-random-wallpaper, because it assumes you use ~/scripts/.

This also assumes there's a directory created called ~/Wallpaper/. Make this directory or change the scripts to reference your personal wallpaper directory.

set-random-wallpaper

Adjust the wget line with your resolution. (hint, you can do this to get it):

xrandr | grep '*'
@srcrip
srcrip / init.vim
Last active July 31, 2020 19:25
My (pretty) simple Neovim config
" Remappings and Commands {{{
nnoremap <silent> <esc> :noh<cr><esc>
nnoremap <space>s :w<CR>
nnoremap gp `[v`]
nnoremap Q @q
nnoremap gj J
nnoremap <c-g> :let @+ = expand("%:p") . ":" . line(".") \| echo 'copied ' . @+ . ' to the clipboard.'<CR>
nnoremap == =ap
nmap <silent> } :<C-u>execute "keepjumps norm! " . v:count1 . "}"<CR>
nmap <silent> { :<C-u>execute "keepjumps norm! " . v:count1 . "{"<CR>
@srcrip
srcrip / bindings.el
Created July 31, 2020 19:50
Here is my (somewhat) simple Doom Emacs config
;;; ~/.doom.d/bindings.el -*- lexical-binding: t; -*-
(map! (:map override
(:after evil-snipe
[remap evil-snipe-s] #'evil-replace-with-register
[remap evil-snipe-S] #'replace-to-end-of-line)
:m "<C-;>" #'goto-last-change
:m "<C-'>" #'goto-last-change-reverse
:nv "C-]" #'xref-find-definitions
;; dired
@srcrip
srcrip / PKGBUILD
Created September 12, 2020 02:19
Insomnia 2020.4.0 PKGBUILD
pkgname=insomnia-designer
pkgver=2020.4.0
pkgrel=1
pkgdesc="The Collaborative API Design Tool for designing and managing OpenAPI specs."
url="https://github.com/Kong/insomnia"
arch=('x86_64')
license=('MIT')
depends=()
makedepends=()
provides=($pkgname)
@srcrip
srcrip / to_indexed_hash.rb
Created February 1, 2021 22:45
Pointless method for turning arrays into hashes based on their positional index
# Converts an array like:
# ["M", nil, "G", nil, "G"]
# to:
# {0=>"M", 1=>nil, 2=>"G", 3=>nil, 4=>"G"}
def to_indexed_hash(arr)
arr.each_with_object({}).with_index { |(el, acc), index| acc[index] = el }
end
# Is this pointless? Probably. I thought it was interesting though.
@srcrip
srcrip / bookmarks.js
Created February 13, 2021 17:36
Flatten the browser bookmarks tree from an extension (Chrome or Firefox)
import browser from 'webextension-polyfill'
// Flatten a tree with 'children' properties recursively
const flattenTree = data => {
return data.reduce((r, { children, ...rest }) => {
if (rest.url) r.push(rest)
if (children) r.push(...flattenTree(children))
return r
}, [])
}
@srcrip
srcrip / context.js
Created February 16, 2021 04:45
Simple example of using a regular React context, and one with a provider
import React, { createContext, useState, useContext } from 'react'
import update from 'immutability-helper'
import './App.css'
const CounterContext = createContext()
const CounterProvider = ({ children }) => {
const [state, setState] = useState({
resources: [
{ name: 'stone', amount: 0 },
@srcrip
srcrip / load-script.js
Created March 2, 2021 20:26
Create and wait on a script tag
function loadScript (src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script')
script.type = 'text/javascript'
script.src = src
script.addEventListener('load', () => resolve(script), false)
script.addEventListener('error', () => reject(script), false)
document.body.appendChild(script)
@srcrip
srcrip / .eslintrc.cjs
Last active August 30, 2023 21:36
Standard ESLint Setup for Svelte
module.exports = {
env: {
browser: true,
es2022: true
},
extends: [
'standard',
'eslint:recommended'
],
parser: '@typescript-eslint/parser',