Skip to content

Instantly share code, notes, and snippets.

View kany's full-sized avatar

Frank Kany kany

  • Rickman, TN
View GitHub Profile
@kany
kany / Azure-SDK-for-Go-and-Azure-REST-API.md
Last active July 7, 2022 13:38
Azure SDK for Go and Azure REST API

Azure SDK for Go and Azure REST API examples

This document details how to create credentials to use when making Azure REST API calls or when using the Azure SDK for Go.

I created this gist because my Golang app was returning empty results and when using the REST API I would see this error message:

{
    "error": {
        "code": "AuthorizationFailed",
        "message": "The client '3c470957-xxxxxx' with object id '3c470957-xxxxxx' does not have authorization to perform action 'Microsoft.Resources/resources/read' over scope '/subscriptions/3dcd5fea-zzzzzz' or the scope is invalid. If access was recently granted, please refresh your credentials."
 }
@dhh
dhh / pagination_controller.js
Last active March 18, 2024 00:00
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>
@kany
kany / delete-old-git-branches.md
Last active February 9, 2022 15:29
Delete old git branches

Delete old git branches

This will delete all branches except for main and feature/foo-bar.

git branch -D `git branch | grep -vE 'main|feature/foo-bar'`

This will delete all branches except for master and branches that begin with kany/SAVE, and kany/hack.

@kany
kany / formatting_xml_or_json.rb
Created February 12, 2019 11:50
Formatting XML or JSON
# resource - http://richardlog.com/post/12743073497/pretty-printing-json-and-xml-on-mac-osx
# Formatting XML
cat unformatted.xml | xmllint --format - > formatted.xml
# Formatting JSON
cat unformatted.json | python -m json.tool > formatted.json

Rails 5 and ActionCable

Assumptions: The application already exists. You have two models article.rb and comment.rb. Articles have two attributes, title and text. Comments have two attributes, text and article_id. See these instructions if you need help getting started.

Routes

Assuming that you are nesting your :comments resources inside of :articles, mount ActionCable and make sure you have a root.

config/routes.rb

Rails.application.routes.draw do
@yellow5
yellow5 / tables_with_foreign_keys.sql
Created February 14, 2013 20:28
Query to list all foreign keys for a given schema in MySQL.
SELECT table_name, constraint_name
FROM information_schema.table_constraints
WHERE
table_schema = 'DATABASE_NAME' AND
constraint_type= 'FOREIGN KEY'
;
@denmarkin
denmarkin / resque.rake
Created September 20, 2011 11:02
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@gus
gus / index.txt
Created November 30, 2009 21:55 — forked from toothrot/index.txt
Ruby/Clojure analogs
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation: