Skip to content

Instantly share code, notes, and snippets.

View daGrevis's full-sized avatar
⌨️
Keyboard operator

Raitis Stengrevics daGrevis

⌨️
Keyboard operator
View GitHub Profile
@daGrevis
daGrevis / init.lua
Created November 27, 2018 15:34
Hammerspoon + AirPods
function airPods(deviceName)
local s = [[
activate application "SystemUIServer"
tell application "System Events"
tell process "SystemUIServer"
set btMenu to (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
tell btMenu
click
]]
..
@daGrevis
daGrevis / simple_sign_in_and_sign_out.py
Created April 20, 2012 08:50
Simple sign in and sign out in Python's Flask
from flask import Flask, session, escape, request, redirect, url_for
from os import urandom
app = Flask(__name__)
app.debug = True
app.secret_key = urandom(24)
@app.route('/')
@daGrevis
daGrevis / bookmarklets_boilerplate.js
Created May 8, 2012 14:15
Bookmarklets boilerplate
javascript:void(function(){var jsCode=document.createElement('script');jsCode.setAttribute('src','http://example.com/script.js');document.body.appendChild(jsCode);}());
const x = [1, 2, 3]
x.reduce((n, acc) => {
if (n > 2) {
return acc
}
return acc + n
}, 0)
nnoremap <Tab> :CocCommand explorer<CR>
call coc#config('explorer', {
\ 'sources': [{'name': 'file', 'expand': 1}],
\ 'file.columns': ['git', 'indent', 'icon', 'filename', 'size', 'readonly'],
\ 'file.showHiddenFiles': 1,
\ 'width': 60,
\ 'icon.enableNerdfont': 1,
\ 'keyMappings.<tab>': 'quit',
\ 'keyMappings.<cr>': 'expandOrShrink'
package main
import (
"encoding/hex"
"fmt"
)
func main() {
var md5, err = hex.DecodeString("7f94dd413148ff9ac9e9e4b6ff2b6ca9")
if err != nil {
package main
import "fmt"
func main() {
var md5 = []byte("7f94dd413148ff9ac9e9e4b6ff2b6ca9")
fmt.Println(len(md5))
}
package main
import "fmt"
func main() {
var md5 = "7f94dd413148ff9ac9e9e4b6ff2b6ca9"
fmt.Println(len(md5))
}
interface PathArray<T, L> extends Array<string | number> {
['0']?: keyof T
['1']?: L extends {
['0']: infer K0
}
? K0 extends keyof T
? keyof T[K0]
: never
: never
['2']?: L extends {
export type MapToBlocValue<T extends {}> = {
[K in keyof T]: T[K] extends BlocSelect<any> ? T[K]['value'] : MapToBlocValue<T[K]>
}