Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@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));
@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'
@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
@castwide
castwide / rails.rb
Last active April 7, 2024 22:10
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
@dominictarr
dominictarr / readme.md
Created November 26, 2018 22:39
statement on event-stream compromise

Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.

@broros

otherwise why would he hand over a popular package to a stranger?

If it's not fun anymore, you get literally nothing from maintaining a popular package.

One time, I was working as a dishwasher in a restu

@aalvarado
aalvarado / _Algorithms_
Last active August 22, 2018 16:48
Algorithms
1
@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"
@itod
itod / split_keyboards.md
Last active April 25, 2024 16:26
Every "split" mechanical keyboard currently being sold that I know of
@t-mart
t-mart / netrw quick reference.md
Last active March 25, 2024 07:47
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@leotm
leotm / findAndReplace.js
Last active March 22, 2022 13:37
Node.js - Find and Replace file(s)
var glob = require('glob');
var fs = require('fs');
var replace = require('replace');
// Find file(s)
glob('fileName.txt', function(err, files) {
if (err) { throw err; }
files.forEach(function(item, index, array) {
console.log(item + ' found');