Skip to content

Instantly share code, notes, and snippets.

from flask import make_response
def cors_response(data):
response = make_response(data)
response.headers['Access-Control-Allow-Origin'] = '*'
return response
from flask import Flask, send_from_directory
import os
app = Flask(__name__)
app.debug = True
_file_directory = 'files/'
@app.route('/')
def directory():
@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 / 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 / NounProjectAPI.cs
Created March 5, 2015 22:50
NounProjectAPI.cs
//taken 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 / 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))
// taken from https://github.com/erndev/NounSample/blob/master/NounSample/NounApiClient.swift
//
// NounApiClient.swift
// NounSample
//
// Created by ERNESTO GARCIA CARRIL on 9/10/15.
// Copyright © 2015 ernesto. All rights reserved.
//
import AppKit
@hirobert
hirobert / .env
Created January 10, 2019 00:45 — forked from schavery/.env
New Relic RQ setup
NEW_RELIC_LICENSE_KEY=6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5
NEW_RELIC_LOG=stdout
NEW_RELIC_APP_NAME=proj--staging
@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: ``