Skip to content

Instantly share code, notes, and snippets.

View AndrewRadev's full-sized avatar

Andrew Radev AndrewRadev

View GitHub Profile
let g:rails_gf_callbacks = [
\ 'RailsGfTranslation'
\ ]
function! RailsGfTranslation()
let saved_iskeyword = &iskeyword
set iskeyword+=.
if !ember_tools#search#UnderCursor('\%(I18n\.\)\=t(\=[''"]\zs\k\+[''"]')
let &iskeyword = saved_iskeyword
@AndrewRadev
AndrewRadev / ember-projections.json
Last active May 6, 2021 17:47
A `.projections.json` file that can be used with vim-projectionist for navigating ember.js projects
{
"app/initializers/*.js": {
"type": "initializer"
},
"app/models/*.js": {
"type": "model",
"alternate": "app/adapters/{}.js",
},
"app/adapters/*.js": {
"type": "adapter",
@AndrewRadev
AndrewRadev / dsf.vim
Last active November 5, 2018 05:01
Delete surrounding function call
" Delete surrounding function call
" Relies on surround.vim
"
" function_call(cursor_here) => dsf => cursor_here
"
" Try `dsf` with more complicated structures:
"
" nested(function_call(cursor_here))
" nested(cursor_here(chewy_center))
" One::Two.new([cursor_here])
require 'rational'
require 'complex'
class Phasor
attr_reader :magnitude, :angle
class << self
def from_polar(magnitude, angle)
new(magnitude, angle)
end
- Standard netrw: https://twitter.com/PascalPrecht/status/489328558700249088
- vim-vinegar: https://github.com/tpope/vim-vinegar
- NERDTree: https://github.com/scrooloose/nerdtree
- Basic usage: navigating, opening a file, opening a directory
- What makes it good:
- powerful navigation
- filesystem manipulation
- customizations
#! /bin/sh
set -e
if [ -z $1 ];
then
echo "USAGE: share-image <image>"
exit 1
fi
" If you've executed a grep/ack command and you have a bunch of stuff in your
" quickfix window, but want to add another grep to it, this could help:
"
" :Ack ProjectCollaborator
" :Qfappend Ack UserCollaborator
"
" This will add the new search results to the end of the quickfix list,
" instead of replacing it. You could also put swap the order by using
" :Qfprepend
"

How I would describe quicksort in an imperative way:

def sort(list):
    pivot is midpoint(list)
    left_part is an empty list
    right_part is an empty list

    for every item in the list
        if the item is smaller than the pivot

add(item) to left_part

require 'sinatra'
get '/play/:choice' do
@player_choice = params[:choice]
choices = ["rock", "paper", "scissors"]
if @player_choice == "random"
@player_choice = choices.sample
end
require 'sinatra'
get '/play/:choice' do
player_choice = params[:choice]
choices = ["rock", "paper", "scissors"]
if player_choice == "random"
player_choice = choices.sample
end