Skip to content

Instantly share code, notes, and snippets.

View alexagranov's full-sized avatar
🍇
tranquiloquint

Alex Agranov alexagranov

🍇
tranquiloquint
View GitHub Profile
@alexagranov
alexagranov / .emacs
Last active June 16, 2019 22:07
my .emacs config
(require 'tls)
(push "/usr/local/etc/libressl/cert.pem" gnutls-trustfiles)
;; ____________________________________________________________________________
;; Aquamacs custom-file warning:
;; Warning: After loading this .emacs file, Aquamacs will also load
;; customizations from `custom-file' (customizations.el). Any settings there
;; will override those made here.
;; Consider moving your startup settings to the Preferences.el file, which
;; is loaded after `custom-file':
@alexagranov
alexagranov / Preferences.el
Created June 8, 2019 01:57
Aquamacs preferences
;; ~/Library/Preferences/Aquamacs Emacs/Preferences.el
;; This is the Aquamacs Preferences file.
;; Add Emacs-Lisp code here that should be executed whenever
;; you start Aquamacs Emacs. If errors occur, Aquamacs will stop
;; evaluating this file and print errors in the *Messags* buffer.
;; Use this file in place of ~/.emacs (which is loaded as well.)
(custom-set-variables
;; custom-set-variables was added by Custom.
@alexagranov
alexagranov / .dir-locals.el
Created April 3, 2019 17:00
Emacs local indent config for web-mode
((web-mode . ((web-mode-code-indent-offset . 2)
(web-mode-css-indent-offset . 2)
(web-mode-markup-indent-offset . 2))))
@alexagranov
alexagranov / bespoke_flatten.rb
Last active March 1, 2018 19:40
Flatten arbitrarily nested arrays without using #flatten :-)
# frozen_string_literal: true
require 'test/unit'
class BespokeFlattenTest < Test::Unit::TestCase
def bespoke_flatten(arr, accum = [])
return arr unless arr.is_a?(Array)
until arr.empty?
elem = arr.shift
elem.is_a?(Array) ? bespoke_flatten(elem, accum) : (accum << elem)
@alexagranov
alexagranov / count_tabs.pl
Created November 2, 2016 19:01
Count number of tabs per line
#!/usr/bin/perl
use strict;
use warnings;
use v5.18;
my $MAX_TABS = 22;
while (<STDIN>) {
chomp $_;
my $c = ($_ =~ tr/\t//);
@alexagranov
alexagranov / html_via_sendmail.sh
Last active August 26, 2016 21:29
send HTML file via `sendmail'
#!/bin/bash
MAILTO="<your.target@email>"
CONTENT="filename.html"
SUBJECT="Subject"
(
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $CONTENT
@alexagranov
alexagranov / git_lfs.rb
Created April 19, 2016 02:59
Custom Overcommit hook to replace the hook installed by git-lfs (which Overcommit removes)
# .git_hooks/pre_push/git_lfs.rb
# Be sure to enable this hook in .overcommit.yml like this:
#
# PrePush:
# GitLfs:
# enabled: true
module Overcommit::Hook::PrePush
class GitLfs < Base
;;; package -- Summary:
;;; Commentary:
;;; Hooks for web mode
;;; Code:
(require 'web-mode)
#!/bin/bash
alias ll='ls -al'
alias gimmeawindow="xterm -b 4 -sb -sl 5000 -geometry 110x60 -vb -fg yellow -bg black -fa \'Consolas\' -fs 16 &"
alias strace='dtruss'
alias start_postgres='pg_ctl -D /usr/local/var/postgres -l /var/log/postgres.log start'
alias stop_postgres='pg_ctl -D /usr/local/var/postgres stop -m fast'
alias ssh_to_master_db='ssh -o TCPKeepAlive=yes -o ServerAliveInterval=300 -L 5452:localhost:5432 root@master-db -p 22'
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)