Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@prabirshrestha
prabirshrestha / .bash_profile
Last active June 3, 2022 01:19
my terminal settings for windows
# curl -Lk https://gist.githubusercontent.com/prabirshrestha/279d8b179d9353fe8694/raw/.bash_profile -o ~/.bash_profile
[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh # This loads NVM
export PATH="$HOME/.cargo/bin:$HOME/go/bin:$HOME/Library/Python/3.7/bin:$PATH"
export PATH="$HOME/.config/nvim/plugins/vim-themis/bin:$PATH"
stty -ixon
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
@rmosolgo
rmosolgo / global_id_changeset.rb
Created January 4, 2022 14:54
Versioning a global ID field in GraphQL-Ruby
require "bundler/inline"
gemfile do
gem "graphql", "1.13.2"
gem "graphql-enterprise", "1.1.0"
end
class BaseField < GraphQL::Schema::Field
include GraphQL::Enterprise::Changeset::FieldIntegration
end
@F0urO4
F0urO4 / average-price.js
Last active January 12, 2023 04:40
average ebay price
var getItems = () => Array.from(document.querySelectorAll('.srp-river-results .s-item__price'));
var getPrices = () => getItems().map((item) => parseFloat((item.textContent.match(/\d+.\d+/)[0])));
var sum = () => getPrices().reduce((a, b) => b + a, 0 );
var getAvg = () => sum() / getPrices().length;
console.log(getAvg().toFixed(2));
@max-b
max-b / .tmux.conf
Created April 6, 2018 23:44
Example of tmux config with more than 2 conditional bindings to single key. Useful for vim-tmux-navigation
# Smart pane switching with awareness of vim and fzf and ctrlp
forward_programs="view|n?vim?|ctrlp"
should_forward="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?($forward_programs)(diff)?$'"
bind -n C-h if-shell "$should_forward" "send-keys C-h" "run-shell '[ #{pane_at_left} -eq 1 ] && tmux previous-window || tmux select-pane -L'"
bind -n C-l if-shell "$should_forward" "send-keys C-l" "run-shell '[ #{pane_at_right} -eq 1 ] && tmux next-window || tmux select-pane -R'"
bind -n C-j if-shell "$should_forward" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$should_forward" "send-keys C-k" "select-pane -U"
bind -n C-\ if-shell "$should_forward" "send-keys C-\\" "select-pane -l"
@aalvarado
aalvarado / aliases.sh
Last active June 5, 2023 23:49
aliases
alias ack='rg --color always --no-block-buffered -n -i'
alias acs='apt-cache search'
alias bd='. bd -s'
alias gb='git branch'
alias gca='git add . && git commit --amend -C HEAD && git push -f'
alias gd='git diff'
alias gdc='git diff --cached'
alias gl=" git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gp='git push -u'
alias gpu='git push -u'
/*!
* jQuery JavaScript Library v2.1.1pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@jirutka
jirutka / pg_change_db_owner.sh
Last active February 6, 2024 20:01
Some convenient scripts to manage ownerships and privileges in PostgreSQL.
#!/bin/sh
#
# The MIT License
#
# Copyright 2014-2017 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end