Skip to content

Instantly share code, notes, and snippets.

@AlexVKO
AlexVKO / add_unaccent_to_postgres
Created September 19, 2015 19:48
Adding extensions to Postgresql database with Rails
The default Postgresql installation on Mac OS X using homebrew includes a single extension - plpgsql (PL/pgSQL procedural language) but there are a number of them available in the lib directory (/usr/local/Cellar/postgresql/9.2.1/lib on my machine)
To install an extension into the database, the easiest way I found was to open a database console using the 'rails db' command and then create it directly. I have seen mention of doing this in a Rails migration but this did not work for me.
Note that an extension is installed in a specific database, rather than being added to all databases.
The command to list the installed extensions is '\dx'
$ rails db
psql (9.2.1)
@AlexVKO
AlexVKO / bidirectional_clipboard.md
Created August 22, 2020 00:34 — forked from jclosure/bidirectional_clipboard.md
Setup a bi-directional shared clipboard between client macos and linux server for remote terminal emacs.

Using netcat and ssh tunnels, create a shared clipboard allowing client and server clipboards to be fused

Serve pbcopy and pbpaste on Mac's localhost

NOTE: That we are making the assumption that the clipboards are sending and receiving UTF-8 encoded bytes

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@AlexVKO
AlexVKO / reload_chrome.sh
Created July 13, 2020 20:00 — forked from jhickner/reload_chrome.sh
Reload Chrome then refocus iTerm
#!/bin/sh
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit
-- the above is some shell trickery that lets us write the rest of
-- the file in plain applescript
tell application "Google Chrome"
activate
tell application "System Events"
tell process "Google Chrome"
{
"jobIds": [
"20748eba-7a5f-4ac6-8ff3-5ce06a045585"
],
"results": [
{
"jobId": "20748eba-7a5f-4ac6-8ff3-5ce06a045585",
"result": {
"data": {
"descriptor": {
@AlexVKO
AlexVKO / airline.vim
Created May 24, 2020 01:43
AlexVKO airline theme
" Minimalist Airline - A Material Color Scheme
"
" Author: Diki Ananta <diki1aap@gmail.com>
" Repository: https://github.com/dikiaap/minimalist
" Version: 2.0
" License: MIT
let s:theme = 'alexvko'
" To highlight when the buffer is modified:
@AlexVKO
AlexVKO / curl.md
Last active March 6, 2020 16:35
Debug/Measure request time using curl

From https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl

cURL supports formatted output for the details of the request (see the cURL manpage for details, under -w, –write-out ). For our purposes we’ll focus just on the timing details that are provided.

Create a new file, curl-format.txt, and paste in:

    time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
   time_pretransfer:  %{time_pretransfer}\n
@AlexVKO
AlexVKO / remotepaste.md
Created July 23, 2018 17:08 — forked from burke/remotepaste.md
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from http://seancoates.com/blogs/remote-pbcopy

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>
@AlexVKO
AlexVKO / passwords_controller.rb
Created November 3, 2015 05:15
Allow devise to reset password signed in
class PasswordsController < Devise::PasswordsController
# here we need to skip the automatic authentication based on current session for the following two actions
# edit: shows the reset password form. need to skip, otherwise it will go directly to root
# update: updates the password, need to skip otherwise it won't even reset if already logged in
skip_before_filter :require_no_authentication, :only => [:edit, :update]
# we need to override the update, too.
# After a password is reset, all outstanding sessions are gone.
# When already logged in, sign_in is a no op, so the session will expire, too.
# The solution is to logout and then re-login which will make the session right.
class Queue
def initialize(max_size: nil)
@head_node = nil
@max_size = max_size
end
def enqueue(element)
if last_node
last_node.next_node = Node.new(element)
else
@AlexVKO
AlexVKO / fedora 27 post
Created April 29, 2018 21:25 — forked from dschier-wtd/fedora 27 post
fedora 27 post installation hints
# Displaimer
This is not a guide or a guideline. It is a collection of ideas, tools and stuff I was/will/am use.
Everything below is very subjectiv and can change over time. If you want to use something from here,
please feel free. But please don't consider it working "as is". In most cases you have to think about stuff.
# Security
## Adjust Firewall
<port close for high ports>