Skip to content

Instantly share code, notes, and snippets.

View samudary's full-sized avatar

Robyn-Dale Samuda samudary

View GitHub Profile
@samudary
samudary / instructions.sh
Created April 26, 2023 20:29 — forked from miguelmota/instructions.sh
linux wireshark SSLKEYLOGFILE ssl decrypt curl
sudo wireshark
# go to:
# Edit -> Preferences -> Protocols -> TLS (you can type) -> under "(Pre)-Master-Secret log filename
" enter in input "/tmp/ssl-key.log"
# then start capture
# curl
SSLKEYLOGFILE=/tmp/ssl-key.log curl https://example.com
# firefox (don't forget to disable http2 in about:config and restart)
@samudary
samudary / ssh.md
Created April 25, 2023 12:42 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@samudary
samudary / python_environment_setup.md
Created June 6, 2021 03:04 — forked from wronk/python_environment_setup.md
Setting up your python development environment (with pyenv, virtualenv, and virtualenvwrapper)

Overview of Python Virtual Environments

This guide is targetted at intermediate or expert users who want low-level control over their Python environments.

When you're working on multiple coding projects, you might want a couple different version of Python and/or modules installed. This helps keep each workflow in its own sandbox instead of trying to juggle multiple projects (each with different dependencies) on your system's version of Python. The guide here covers one way to handle multiple Python versions and Python environments on your own (i.e., without a package manager like conda). See the Using the workflow section to view the end result.


h/t @sharkinsspatial for linking me to the perfect cartoon

@samudary
samudary / gist:533fae9e2d4a58538414f52a47cfdffe
Created May 25, 2021 13:34 — forked from jwebcat/gist:5122366
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@samudary
samudary / helper.rb
Created January 1, 2021 15:05 — forked from swanson/helper.rb
# Formats a +number+ into an abbreviated string suitable for
# displaying social media type metrics
#
# ==== Options
# * start_at - The first number to start abbreviating, defaults
# to 10_000. Certain metrics may want to start at e.g. 1000.
#
# ==== Examples
# number_to_social(123) # => 123
# number_to_social(1457) # => 1457
@samudary
samudary / sign_in.rb
Created June 22, 2020 21:48 — forked from americodls/sign_in.rb
Interface proposal for ServiceObject/Interactor/UseCase on rails
class SessionsController < ApplicationController
def create
ToDoList::SignIn.new(sign_in_params).call({
success: ->(message) { redirect_to dashboard_user_path, notice: t(message) },
failure: ->(message) { render :new, error: t(message) }
})
end
end
module ToDoList
@samudary
samudary / git_rebase.md
Created June 19, 2020 18:35 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@samudary
samudary / presenters.md
Created May 10, 2018 18:16 — forked from somebox/presenters.md
Thoughts About Rails Presenters

Thoughts about Rails Presenters

This is a collection of links, examples and rants about Presenters/Decorators in Rails.


The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.

Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html

#!/usr/bin/env bash
#
# drip_ssh_proxy.sh
#
# Attempts to pull private ip address from hostname pattern.
# assumes ruby is present on the system.
HOST_PORT="$1"
if [[ -z "$HOST_PORT" ]]; then
>&2 echo "host:port is required"
@samudary
samudary / friendly_urls.markdown
Created September 24, 2017 21:02 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.