Skip to content

Instantly share code, notes, and snippets.

View twlz0ne's full-sized avatar

twlz0ne

  • Fuzhou, China
View GitHub Profile
@twlz0ne
twlz0ne / rotate-screen-90-degrees.applescript
Last active August 22, 2023 12:42
Rotate Display using AppleScript for MacOSX 10.6.8
tell application "System Preferences"
quit
delay 1
launch
activate
tell application "System Events"
key down {option, command}
end tell
reveal pane id "com.apple.preference.displays"
tell application "System Events"
@twlz0ne
twlz0ne / advice-remove-button.el
Created July 2, 2022 02:27
Add button to remove advice in help-mode #emacs
(defun function-advices (function)
"Return FUNCTION's advices.
Last-Updated 2022-06-29 00:01:07 +8000"
(let ((flist (indirect-function function)) advices)
(when (and (consp flist)
(or (eq 'macro (car flist))
(and (autoloadp flist) (memq (nth 4 flist) '(macro t)))))
(setq flist (cdr flist)))
(while (advice--p flist)
@twlz0ne
twlz0ne / here-emacs
Last active December 15, 2022 08:25
Launch emacs from emacs.d folder you placed anywhere.
#!/usr/bin/env bash
#
# Launch emacs from emacs.d folder you placed anywhere.
#
# @author gongqijian@gmail.com
# @created 2016-07-21
# @version 0.6
# @last-updated 2022-12-15 15:51:23 +0800
#
@twlz0ne
twlz0ne / git-checkout-pr.sh
Created November 14, 2022 06:59
Checkout Github pull-request locally. #git
#!/usr/bin/env sh
:; # -*- mode: emacs-lisp; lexical-binding: t -*-
:; # Checkout Github pull-request locally.
:; # Last-updated: 2022-11-14 13.42.02 +0800
:; # by: Gong Qijian
:; # Usage:
:; # git-checkout-pr.sh [pull-request-url]
:; # Example:
:; # git-checkout-pr.sh https://github.com/user1/project2/pull/3
:; #
; $Id: helm-ls.el,v 1.4 2018/01/22 21:39:56 thierry Exp $
(defvar helm-source-ls
(helm-build-async-source "ls"
:candidates-process (lambda ()
(let* ((basedir (if (file-directory-p helm-pattern)
helm-pattern
(helm-basedir helm-pattern)))
(proc
(start-file-process "hls" nil "ls"
@twlz0ne
twlz0ne / custom-firefox-search-engine.el
Last active July 23, 2022 15:39
Custom Firefox Search Engine #Emacs
(cl-defun custom-firefox-search-engine (&key
name
description
iconurl
searchurl
&allow-other-keys)
"Custom Firefox Search Engin.
NAME Short name of search engine
DESCRIPTION Description of search engine
@twlz0ne
twlz0ne / company-transformer-capf-dabbrev.el
Last active July 4, 2022 03:43
Return different CANDIDATES depending on the point position #emacs #company #lsp
(defun company-transformer//capf-dabbrev (candidates)
"Return different CANDIDATES depending on the point position.
| point at | company-capf | company-dabbrev |
|:---------|:------------:|:---------------:|
| foo.| | ✅ | ❌ |
| \"foo|\" | ❌ | ✅ |
| foo| | ✅ | ✅ |
Inspired by @yyjjl's [company//sort-by-tabnine](https://emacs-china.org/t/tabnine/9988/40)
@twlz0ne
twlz0ne / emacs-pager
Last active May 22, 2022 09:08
Emacs as Pager
#!/usr/bin/env bash
set -e
# Emacs as pager
#
# Author: gongqijian@gmail.com
# Created: 2021-06-06 16.08.51
# Version: 0.1
#
# Installation:
@twlz0ne
twlz0ne / git-workflow.svg
Last active April 16, 2022 14:11
git workflow
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@twlz0ne
twlz0ne / howto-keeping-a-feature-branch-update-with-upstream.md
Created October 10, 2013 01:57
git feature branch 如何跟踪上游变化?

基于上游仓库某次提交做了修改

----(a)---------------> upstream/up_master
      \
------(b)-------------> origin/my_master

一段时间之后,上游仓库更新了

----(a)--(c)--(d)--(e)--(f)--(g)--> upstream/up_master