Skip to content

Instantly share code, notes, and snippets.

@na0x2c6
na0x2c6 / mic-toggle.applescript
Created May 12, 2021 08:10
Mic mute toggle script on Mac
-- refs: https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ReadandWriteFiles.html
-- refs: https://medium.com/macoclock/how-in-the-bleep-do-i-mute-my-mic-anywhere-on-macos-d2fa1185b13
on writeTextToFile(theText, theFile, overwriteExistingContent)
try
set theFile to theFile as string
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
@na0x2c6
na0x2c6 / Vagrantfile
Last active March 17, 2021 12:16
Vagrantfile to use podman on Mac OS
Vagrant.configure("2") do |config|
# refs: https://app.vagrantup.com/fedora
config.vm.box = "fedora/33-cloud-base"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
# https://www.vagrantup.com/docs/synced-folders/nfs
@na0x2c6
na0x2c6 / tmux.conf
Last active August 28, 2021 04:27
a simple tmux conf
# prefix
set -g prefix C-q
unbind C-b
# keystroke delay
set -sg escape-time 1
# to reload
bind r source-file ~/.tmux.conf \; display "Reloaded!"
@na0x2c6
na0x2c6 / fedora-vim-build.sh
Created February 21, 2021 23:51
Script to build Vim on Fedora
CFLAGS=-fPIC ./configure \
--with-tlib=ncurses \
--with-features=huge \
--with-x \
--enable-multibyte \
--enable-luainterp=dynamic \
--enable-gpm \
--enable-cscope \
--enable-fontset \
--enable-fail-if-missing \
@na0x2c6
na0x2c6 / build.sh
Last active March 4, 2022 06:25
build Vim on OS X (Mac)
./configure \
--prefix=$HOME/local \
--enable-multibyte \
--enable-nls \
--enable-perlinterp \
--enable-pythoninterp=dynamic \
--enable-python3interp=dynamic \
--enable-rubyinterp \
--enable-luainterp --with-lua-prefix=/usr/local \
--enable-cscope \
@na0x2c6
na0x2c6 / zshrc.zsh
Last active June 5, 2021 02:50
part of my zshrc
export EDITOR='vim'
export VISUAL='vim'
export PAGER='less'
# for `Ctrl + w`
export WORDCHARS='*?_.[]~-=&;!#$%^(){}<>'
export DIRSTACKSIZE=8
bindkey -e
setopt clobber
@na0x2c6
na0x2c6 / build.sh
Last active May 3, 2020 02:00
Building vim from the source on Ubuntu 18.04 LTS
sudo apt install \
lua5.2 \
liblua5.2-dev \
luajit \
ruby-dev \
xorg-dev \
libncurses5-dev
./configure \
--with-features=huge \
@na0x2c6
na0x2c6 / some-component.ts
Created March 22, 2020 11:00
LitElement with embed a scss (for IE).
import { LitElement, html, unsafeCSS } from 'lit-element';
import style from './scss/style.scss';
@customElement('some-component')
export default class SomeComponent extends LitElement {
static get styles() {
return [
// If you don't need to consider IE, you can use a link tag to include style in the render function.
unsafeCSS(style),
]
@na0x2c6
na0x2c6 / index.html
Last active April 5, 2020 04:20
The set for building an app using LitElement, considering IE.
<script type="text/javascript">
// Write me in the head tag.
// For this sample, you need to put `@webcomponents/webcomponentsjs/` dirctory from the node_modules into `your-doc-root/js/` dirctory.
(function() {
if (('customElements' in window)) {
document.write('<script defer type="text/javascript" src="/js/main.js"><\/script>');
} else {
document.write('<script defer type="text/javascript" src="/js/@webcomponents/webcomponentsjs/webcomponents-loader.js"><\/script>');
window.WebComponents = window.WebComponents || {};
window.WebComponents.root = '/js/@webcomponents/webcomponentsjs/';
@na0x2c6
na0x2c6 / calcOffset.ts
Created March 22, 2020 07:21
Calculating an element node offset.
function calcOffset(elm: HTMLElement) {
const offset = {
top: 0,
left: 0,
}
do {
offset.top += elm.offsetTop || 0;
offset.left += elm.offsetLeft || 0;
} while((elm = elm.offsetParent as HTMLElement));