Skip to content

Instantly share code, notes, and snippets.

View listenlight's full-sized avatar

Jesse Crockett listenlight

  • Texas
  • 22:07 (UTC -06:00)
View GitHub Profile
@listenlight
listenlight / .bash_functions
Created June 24, 2021 11:22
bash function to add aliases just-in-time and reload the .bash_aliases file
#!/bin/bash
# add alias definitions on the go,
# and reload .bash_aliases into your current shell
function addalias() {
read -p "alias name: " alias_name
read -p "alias cmd: " alias_cmd
cmd_str="alias $alias_name=\"$alias_cmd\""
the_rest=" >> ~/.bash_aliases && . ~/.bash_aliases"
@listenlight
listenlight / discourse-wordcount.rb
Created April 14, 2022 11:57
Basic functionality for word count of replies to a topic, not counting author's posts
# plugins/wordcount/plugin.rb
after_initialize do
  add_to_serializer(:topic_list_item, :word_count_of_replies) do
    object.posts.where.not(user: object.user).sum(:word_count)
  end
end
# topic-posts-column.hbr
<{{view.tagName}} class='num posts-map posts {{view.likesHeat}} topic-list-data' title='{{view.title}}'>
  <button class="btn-link posts-map badge-posts {{view.likesHeat}}" aria-label="{{view.title}}">
apps='ps cexmo pid,user,comm | gvg -E '\''(nginx|puma|redis|postgresq|apache|bundler|ruby|/gem|sidekiq)'\'
#!/bin/zsh
function ww() {
wcmd=$1
echo $'\e[1;34m'$(which $wcmd)$'\n\e[0m\e[0;34m'$(whereis $wcmd)$'\e[0m';
}
function addalias() {
read 'tmpAlias?shortcut: '