Skip to content

Instantly share code, notes, and snippets.

View cherryramatisdev's full-sized avatar
🏠
Working from home

Cherry Ramatis cherryramatisdev

🏠
Working from home
View GitHub Profile
@cherryramatisdev
cherryramatisdev / pull_request.lua
Last active October 12, 2023 23:55
Simple module to manage pull request creation within neovim
local M = {}
---@return 'main' | 'develop'
local function decide_base_branch()
if vim.fn.system 'git branch --contains develop' == 'error: malformed object name develop' then
return 'main'
end
return 'develop'
end
function! project#Switch(path) abort
if tabpagenr('$') == 1
%bd
endif
execute 'cd ' . a:path
execute 'Dirvish'
endfunction
function! s:ReturnProjectRoot() abort
" TODO: This doesn't work on non git projects
return system('git rev-parse --show-toplevel')->substitute('\n', '', '')
endfunction
function! github#pr#CreatePr() abort
let l:template_path = s:ReturnProjectRoot() . '/.github/pull_request_template.md'
call execute('tabe ' . tempname())
gui:
# stuff relating to the UI
windowSize: 'normal' # one of 'normal' | 'half' | 'full' default is 'normal'
scrollHeight: 2 # how many lines you scroll by
scrollPastBottom: true # enable scrolling past the bottom
scrollOffMargin: 2 # how many lines to keep before/after the cursor when it reaches the top/bottom of the view; see 'Scroll-off Margin' section below
scrollOffBehavior: 'margin' # one of 'margin' | 'jump'; see 'Scroll-off Margin' section below
sidePanelWidth: 0.3333 # number from 0 to 1
expandFocusedSidePanel: false
mainPanelSplitMode: 'flexible' # one of 'horizontal' | 'flexible' | 'vertical'
#!/usr/bin/env perl
use strict;
use warnings;
use v5.14;
my $arg = $ARGV[0];
if ( defined $arg ) {
@cherryramatisdev
cherryramatisdev / console.rb
Last active September 3, 2023 15:44
A sample IRB configuration for ruby projects, save it in bin/console
#!/usr/bin/env ruby
# Ensure that the 'lib/' directory is in the load path
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
# Load all .rb files in the lib/ directory
Dir[File.expand_path('../lib/*.rb', __dir__)].each { |file| require file }
# Start an IRB session
require 'irb'
#!/usr/bin/env bash
passwords=$(bw list items | jq '.[] | {id: .id, name: .name}')
selected_password=$(echo "$passwords" | jq -r '.name' | fzf)
selected_password_id=$(echo "$passwords" | jq "select(.name == \"$selected_password\").id" | tr -d '"')
password=$(bw get item "$selected_password_id")
if [[ "$password" != "" ]]; then
echo "Copied password from $selected_password with $(echo "$password" | jq '.login.username') username to clipbord..."
def reload!(print: true)
puts 'Reloading ...' if print
# Main project directory.
root_dir = Dir.pwd
# Directories within the project that should be reloaded.
reload_dirs = %w[lib app]
# Loop through and reload every file in all relevant project directories.
reload_dirs.each do |dir|
Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
end
function! TransformSplitIntoTab() abort
let l:path = expand('%')
call execute(':wq!')
call execute(':tabnew ' . l:path)
endfunction
nnoremap <c-w>! :call TransformSplitIntoTab()<cr>
" styled.vim Provide refactors for styled-components related components.
function! s:mountStyledConstant(target, original) abort
let l:styled_prefix = 'styled.'.a:original
if a:original =~ '^\u'
let l:styled_prefix = printf('styled(%s)', a:original)
endif
return printf('export const %s = %s``;', a:target, l:styled_prefix)