Skip to content

Instantly share code, notes, and snippets.

@chenglaihuang
chenglaihuang / DuolingoMethodTrace.kt
Last active October 15, 2025 21:15
duolingo-method-trace
/*
* Copyright 2025 Duolingo, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@rougier
rougier / dual-header.el
Created December 30, 2024 19:08
Emacs dual header line
;; Dual header line is possible by exploiting the tab-bar line that
;; sits on top of the header line and is generally hidden. For the
;; icon, it has to be precisely cut in top and bottom part and each
;; part is concatenated with either the tab-line or header-line.
(defun dual-header (top bottom)
"This installs a double line header in current buffer using both tab line (TOP) and header line (BOTTOM)."
(set-face-attribute 'tab-line (selected-frame)
@gpeal
gpeal / FragmentA.kt
Last active October 2, 2024 04:10
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 February 19, 2025 07:47
pre-commit git hook file for Golang. 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