Skip to content

Instantly share code, notes, and snippets.

@DevNebulae
DevNebulae / TickHandler.kt
Last active October 11, 2022 23:32
Lifecycle-aware class intended to be used to handle periodic tasks. Its main purpose is to handle periodic tasks in a viewmodel (e.g. refreshing a list from a web service)
// Uses packages:
// * org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlin.time.Duration
@DevNebulae
DevNebulae / doodle@DistanceCalculation.kts
Last active October 1, 2021 17:57
Intended to be used in an IntelliJ scratch pad.
// Distance is assumed to be in whole km and volume in whole L
data class Refuel(val distance: Int, val volume: Int)
data class Vehicle(val odometer: Int, val trip: Int, val refuels: List<Refuel> = emptyList())
val vehicle = Vehicle(odometer = 25000, trip = 300, refuels = listOf(
Refuel(distance = 700, volume = 33),
Refuel(distance = 1100, volume = 48)
))
@DevNebulae
DevNebulae / init.vim
Last active November 10, 2019 21:00
init.vim
call plug#begin()
Plug 'airblade/vim-gitgutter'
Plug 'editorconfig/editorconfig-vim'
Plug 'itchyny/lightline.vim'
Plug 'neomake/neomake'
Plug 'scrooloose/nerdtree'
" Haskell
Plug 'neovimhaskell/haskell-vim'
@DevNebulae
DevNebulae / track-gql.js
Created December 9, 2017 14:41
GraphQL circular dependencies gql tag
const TrackType = gql`
type Track {
albums: [Album!]
artists: [Artist!]
title: String!
}
`
export default () => [AlbumType, ArtistType, TrackType]
@DevNebulae
DevNebulae / track.js
Created December 9, 2017 09:56
GraphQL discography graphql-tools
import gql from "graphql-tools"
const TrackType = gql`
type Track {
albums: [Album!]!
artists: [Artist!]!
title: String!
}
`
@DevNebulae
DevNebulae / album.graphql
Last active December 9, 2017 14:43
GraphQL discography
type Album {
artists: [Artist!]
title: String!
tracks: [Track!]
}
@DevNebulae
DevNebulae / generate_html.py
Created September 16, 2017 16:45
Python shenanigans - a collection of fun python scripts
"""
General script to retrieve all HTML elements in the HTML5
spec and generate a general module
"""
from functools import reduce
import urllib.request
def create_module(module_name, functions, content):
"""
@DevNebulae
DevNebulae / html-attributes.txt
Last active September 18, 2017 06:57
HTML spec
accept
accept-charset
accesskey
action
alt
async
autocomplete
autofocus
autoplay
challenge
@DevNebulae
DevNebulae / .proton
Last active April 4, 2017 06:58
Proton(-mode) configuration
{
;; This is your main proton configuration file
;; While using proton, all atom related configuration has to go inside here
;; Everything that is not set up through this file will get wiped on start
;; We gave you some cool defaults below but if you don't like it, feel free to change :)
;; Layers you wish to have active
;; To get a list of all available layers, check github.com/dvcrn/proton/tree/master/src/cljs/proton/layers
:layers [
;; -----------------------------------