Skip to content

Instantly share code, notes, and snippets.

# Works as famous command which is exist in simple.el
# https://github.com/emacs-mirror/emacs/blob/cbc10ec71e9f189e8d6fd5c6927aec4872e0fd96/lisp/simple.el#L957
# + Feature that I implement for function is you can select text as region than it will delete spaces if it's more than 1.
# - Feature: Base function allows you leave (n)Space I don't need this, so it is not exist.
(defun just-one-space-region (begin end)
"Deletes whitespaces for selected region if they more than one"
(interactive "r")
(if (use-region-p)
(save-excursion
# Works as famous command which is exist in simple.el
# https://github.com/emacs-mirror/emacs/blob/cbc10ec71e9f189e8d6fd5c6927aec4872e0fd96/lisp/simple.el#L957
# + Feature that I implement for function is you can select text as region than it will delete spaces if it's more than 1.
# - Feature: Base function allows you leave (n)Space I don't need this, so it is not exist.
(defun just-one-space-region (begin end)
"Deletes whitespaces for selected region if they more than one"
(interactive "r")
(if (use-region-p)
(save-excursion
# https://github.com/jhawthorn/fzy
# I have just discovered what is fzy. I created helpful functions that helps to edit or navigte directories at the light of speed
# I'm agree with you that function could be more simple :)
# Use the force wisely
alias git-root='cd $(git rev-parse --show-toplevel)'
# Change directory and don't show hidden directories like .git in the git repository
function cdinproject() {
@enisozgen
enisozgen / auto-upper-case-aws-acronyms.el
Last active January 28, 2019 10:54
Emacs lisp code that automaticaly uppercase acronyms
;; Auto upper case or camel case AWS related acronyms and words
;; stop asking whether to save newly added abbrev when quitting emacs
(setq save-abbrevs nil)
;; org-hook
(add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
@enisozgen
enisozgen / fast-highlight.el
Created October 21, 2017 18:34
Fast highlight options that I use
(setq enis-highlight-symbol-packages
'(
highlight-symbol
))
(defun enis-highlight-symbol/init-highlight-symbol ()
(use-package highlight-symbol
:config
(setq highlight-symbol-idle-delay 0.01)
@enisozgen
enisozgen / ansible-nested-variable.yml
Last active November 4, 2023 10:21
Ansible example which shows how to reach nested variable with dynamic elements
# Example which shows how to reach nested ansible variable which is partially different.
# Run that plabook with ansible-playbook -e "env=test" ansible-nested-variable.yml
---
#
- hosts: localhost
connection : ssh
gather_facts: no
vars:
cidr_blocks:
vpc_production_cidr_block: "10.10.0.0/28"
@enisozgen
enisozgen / hydra-git-gutter.el
Created April 22, 2017 10:34
Nice diff's gonna save your time
;; Few changes to https://github.com/abo-abo/hydra/wiki/Git-gutter
(defhydra hydra-git-gutter (:body-pre
(save-buffer)
(git-gutter-mode 1)
:hint nil
:color blue)
"
Git gutter:
_n_: next hunk _s_tage hunk _u_ndo _r_edo _q_uit
_p_: previous hunk _R_evert hunk ^ ^ _Q_uit and deactivate git-gutter
; I don't know where I stole it but it works well
(defun open-terminal-pop-project-root ()
(interactive)
(do-applescript
(format "
tell application \"iTerm 2\"
tell current window
tell current session
write text \"cd %s\"
end tell
@enisozgen
enisozgen / CalculateEBSVolumes.sh
Last active February 20, 2017 11:35
Show all EBS volumes size by filtering any environment
# Shows all volumes of any environment
REGION='us-east-1'
VOLUMES=$(aws ec2 describe-instances --region=$REGION --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs' --filter "Name=tag:Environment,Values=Uat" --output text | awk '{print($4)}')
echo "Your volumes $VOLUMES"
for VOLUME in $VOLUMES
@enisozgen
enisozgen / is_command_exist.yml
Last active November 7, 2023 18:45
ansible tasks that Checks if a program exists from a Bash script
- name: Check is rvm installed
shell: command -v rvm >/dev/null 2>&1
register: is_rvm_exist
ignore_errors: yes
- debug: msg="{{ is_rvm_exist.rc }}" # it returns rc 1
- debug: var=is_rvm_exist
- name: Check is ls installed
shell: command -v ls >/dev/null 2>&1