Skip to content

Instantly share code, notes, and snippets.

@gpeal
gpeal / FragmentA.kt
Last active December 27, 2023 06:50
View Binding Delegates
class WifiNetworksFragment : TonalFragment(R.layout.wifi_networks_fragment) {
// This automatically creates and clears the binding in a lifecycle-aware way.
private val binding: WifiNetworksFragmentBinding by viewBinding()
...
}
class WifiNetworkView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
(defun org-mode-export-myfile ()
"Export org document to HTML automatically on change"
(when (equal (buffer-file-name) "/path/to/links.org")
(progn
(org-html-export-to-html)
(message "HTML exported"))))
(add-hook 'after-save-hook 'org-mode-export-myfile)
@alphapapa
alphapapa / let-it-snow.el
Last active January 3, 2020 17:15
Let it snow in Emacs! Moved to dedicated repo: https://github.com/alphapapa/snow.el
;; Moved to dedicated repo: https://github.com/alphapapa/snow.el
@radlinskii
radlinskii / pre-commit.sh
Last active October 5, 2022 15:56
pre-commit git hook file for working in Go. Be sure to save this file in your repository as `.git/hooks/pre-commit` and give it right to execute e.g. with command `chmod +x .git/hooks/pre-commit`
#!/bin/sh
STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$")
if [[ "$STAGED_GO_FILES" = "" ]]; then
exit 0
fi
GOLINT=$GOPATH/bin/golint
GOIMPORTS=$GOPATH/bin/goimports
@masahirompp
masahirompp / ImageUtils.ts
Last active October 8, 2017 04:59
image file to DataUri, DataUri(or image src) to ImageData
export function imageFileToDataUri (file: File) {
return new Promise<string>(done => {
const reader = new FileReader()
reader.onloadend = () => done(reader.result)
reader.readAsDataURL(file)
})
}
export function imageSrcToImageData (imageSrc: string) {
return new Promise<ImageData>(resolve => {
@masahirompp
masahirompp / react-svg-pan-zoom.d.ts
Created February 25, 2017 14:14
react-svg-pan-zoom.d.ts
declare module 'react-svg-pan-zoom' {
import * as React from 'react'
type Tool = 'auto' | 'none' | 'pan' | 'zoom-in' | 'zoom-out'
type ToolBarPosition = 'none' | 'top' | 'right' | 'bottom' | 'left'
export const ReactSVGPanZoom: ReactSVGPanZoom
interface ReactSVGPanZoom extends React.ComponentClass<ReactSVGPanZoomProps> {}
public class AnnotationHelper {
private static final String ANNOTATIONS = "annotations";
public static final String ANNOTATION_DATA = "annotationData";
public static boolean isJDK7OrLower() {
boolean jdk7OrLower = true;
try {
Class.class.getDeclaredField(ANNOTATIONS);
} catch (NoSuchFieldException e) {
//Willfully ignore all exceptions
@cobalamin
cobalamin / HaskellVsElm.md
Last active April 2, 2022 09:19
Elm (0.17) syntax and functionality differences for Haskell programmers
  • Types are declared with : and not ::, and the consing operator conversely is :: instead of :
  • No where clauses, only let/in
  • The standard style is different, check http://elm-lang.org/docs/style-guide for reference
  • Multiline strings are a thing with """
  • Haskell's data corresponds to type in Elm, and also, Haskell's type corresponds to Elm's type alias
  • ($) is (<|), but you don't use it all that much – Elm people like the flipped operator (|>) which lets you build something that reads like a pipeline
  • Related: Backticks will likely die soon in favour of functions that have an argument order that lends itself to pipelining with (|>)
  • Also, (.) is (<<), and a flipped version (>>) exists, but I don't see it used that much either
  • (&gt;&gt;=) is not an available operator and would not be polymorphic (no typeclasses, see below), and is instead commonly named SomeType.andThen – e.g. Maybe.andThen : Maybe a -&gt; (a -&gt; Maybe b) -&gt; Maybe b
@DenisIzmaylov
DenisIzmaylov / NOTES.md
Last active November 15, 2019 07:39
Step By Step Guide to Configure a CoreOS Cluster From Scratch

Step By Step Guide to Configure a CoreOS Cluster From Scratch

This guide describes how to bootstrap new Production Core OS Cluster as High Availability Service in a 15 minutes with using etcd2, Fleet, Flannel, Confd, Nginx Balancer and Docker.

Content