This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "Custom Layout Switch", | |
"rules": [ | |
{ | |
"description": "CapsLock to switch to English layout", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "caps_lock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Usage: | |
urlretrieve(source_url, filename, reporthook=ProgressBar()) | |
""" | |
class ProgressBar: | |
def __init__(self): | |
self.tqdm = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Node[T any] struct { | |
Val T | |
Next *Node[T] | |
} | |
type LinkedList[T any] struct { | |
Head *Node[T] | |
Tail *Node[T] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Error struct { | |
parent error | |
msg string | |
} | |
func NewError(msg string) *Error { | |
return &Error{msg: msg} | |
} | |
func (err *Error) New(msg string) *Error { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
KEY_CODE=55 # Command Key | |
MAX_IDLE=30 | |
while true; do | |
idle=`ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'` | |
echo "Current idle: $idle" | |
if [[ $idle > $MAX_IDLE ]]; then | |
osascript -e "tell application \"System Events\" to key code $KEY_CODE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib import admin | |
from django.shortcuts import redirect | |
class SingletonModel(models.Model): | |
class Meta: | |
abstract = True | |
def save(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://diamantidis.github.io/tips/2020/07/01/list-makefile-targets | |
# With support of multiple words in the help meessage | |
.DEFAULT_GOAL := help | |
.PHONY: help test | |
help: | |
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | |
| sed -n 's/^\(.*\): \(.*\)## \(.*\)/\1;\3/p' \ | |
| column -t -s ';' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--main-color: #FCAF1B; | |
--second-color: #F17124; | |
} | |
/* admin header */ | |
#header { | |
background: var(--main-color); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Union, Any, List, Tuple, Dict | |
import copy | |
_ExpressionTuple = Tuple[str, str, Any] | |
_Expression = Union[str, _ExpressionTuple] | |
_ExpressionOrBuilder = Union[_Expression, "WhereClauseBuilder"] | |
class WhereClauseBuilder: | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
import inspect | |
def singleton(func): | |
@wraps(func) | |
def decorator(): | |
if not hasattr(func, "instance"): | |
func.instance = func() | |
return func.instance |
NewerOlder