Skip to content

Instantly share code, notes, and snippets.

@hirobert
hirobert / OAuth.php
Last active April 30, 2024 17:14
Noun Project API - PHP Example
<?php
// mirror of: http://oauth.googlecode.com/svn/code/php/OAuth.php
// vim: foldmethod=marker
/* Generic exception class
*/
class OAuthException extends Exception {
// pass
}
var OAuth = require('oauth')
// `npm install oauth` to satisfy
// website: https://github.com/ciaranj/node-oauth
var KEY = "<INSERT KEY HERE>"
var SECRET = "<INSERT SECRET HERE>"
var oauth = new OAuth.OAuth(
'http://api.thenounproject.com',
'http://api.thenounproject.com',
@hirobert
hirobert / response-content-disposition-cloudfront.txt
Last active December 21, 2023 20:38
response-content-disposition and cloudfront
1) Log in to aws console.
2) Click cloudfront
3) Click behaviors
4) Select pattern and edit
@hirobert
hirobert / empty-rq-failed-queue.py
Created October 12, 2023 18:58
Fix Stuck Jobs in RQ Failed Queue
# If RQ thinks there are failed jobs
# but they do not exist in Redis
# and RQ-Dashboard cannot remove/requeue them
from redis import Redis
from rq import Queue
from rq.registry import FailedJobRegistry
from rq.exceptions import NoSuchJobError
redis_rq = Redis(host=REDIS_SERVER, port=6379, db=1)
@hirobert
hirobert / flask_abort_example.py
Created January 13, 2016 20:38
flask abort as json
from flask import abort, make_response, jsonify
abort(make_response(jsonify(message="Message goes here"), 400))
<?php
class OAuthException extends Exception
{
// pass
}
class OAuthConsumer
{
public $key;
var OAuth = require('oauth')
// `npm install oauth` to satisfy
// website: https://github.com/ciaranj/node-oauth
var KEY = "<INSERT KEY HERE>"
var SECRET = "<INSERT SECRET HERE>"
var oauth = new OAuth.OAuth(
'http://api.thenounproject.com',
'http://api.thenounproject.com',
// adapted from https://github.com/KaneQc/Noun-Project-API/blob/master/NounProjectAPI.cs
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Request
@hirobert
hirobert / aws-load-balancer-elb-alb-target-group-target-currently-in-use-by-a-listener-or-a-rule.md
Last active August 25, 2022 22:58
aws load balancer (elb/alb) target group - target currently in use by a listener or a rule

This is likely happening because there are still rules associated with the load balancer that are using the target group. Unfortunately there is currently on way in the AWS console to view or edit the rules. Here is another approach:

  1. Install AWS cli: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
  2. If you have different profiles, add --profile=name_of_profile on each of the following commands
  3. aws elbv2 describe-load-balancer, get the load balancer arn
  4. aws elbv2 describe-listeners --load-balancer-arn arn:aws:elasticloadbalancing:this_is_the_load_balancer_arn, get listener arn for the listener which you associated with the target group
  5. aws elbv2 describe-rules --listener-arn arn:aws:elasticloadbalancing:this_is_the_listener_arn, get the rule arn which should contain the name of the target group you are looking to remove
  6. aws elbv2 delete-rule --rule-arn arn:aws:elasticloadbalancing:this_is_the_rule_arn
@hirobert
hirobert / ubuntu-docker-credential-desktop-fix.md
Created July 21, 2022 19:19
How to fix Ubuntu docker-credential-desktop error

How to fix Ubuntu docker-credential-desktop error

Errors:

failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``
Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``