Skip to content

Instantly share code, notes, and snippets.

View skabbes's full-sized avatar

Steven Kabbes skabbes

  • Dropbox
  • Phoenix, AZ
View GitHub Profile
/* Fetch a file from s3 as a Stream
*
* @param fileId the fileId to fetch
* @return {stream: Stream, meta, contentType, contentLength}
*/
export async function fetchStream({ fileId }) {
try {
const key = makeS3Key(fileId);
const fileOpts = { Bucket: BUCKET, Key: key };
const { stream, data } = await Promise.props({
@skabbes
skabbes / redirect.js
Created August 27, 2019 01:02
This is a AWS S3 secure redirect to a file
// secureRedirect redirects this fileId to be loaded directly from S3.
// if filename is provided, it will trigger a download of that filename
export function secureRedirect({ reply, fileId, filename }) {
const key = makeS3Key(fileId);
let contentDisposition;
if (filename && Buffer.from(filename, 'utf8').toString('ascii') === filename) {
contentDisposition = `attachment; filename="${filename}"`;
} else if (filename) {
const encodedFilename = Querystring.escape(filename);
contentDisposition = `attachment; filename*=UTF-8''${encodedFilename}`;
@skabbes
skabbes / lambda_cleanup.go
Created August 21, 2019 07:00
A quick script coded up to free space used to old lambda versions
package command
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/lambda"
// https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet
var ss = SpreadsheetApp.openById("yourSpreadSheetIdHere");
var dataSheet = ss.getSheetByName("data sheet name");
var historySheet = ss.getSheetByName("Historical");
var cell = dataSheet.getRange("A1");
historySheet.appendRow(["a man", "a plan", "panama"]);
@skabbes
skabbes / README.md
Last active May 5, 2021 20:57
react-navigation with react-native web webpack config

These files aren't complete, but they are plucked out from a successful (closed-source) usage of react-navigation 1.5.8 with react-native-web@latest.

While a blog post would be nice when I have a minute free, I'd like to give this to someone who wants to give it a try before I do.

@skabbes
skabbes / example talon3 output
Last active August 29, 2015 14:22
This shows an example of the fields that talon3 can parse.
{ subject: 'Plantar Fasciitis Therapy Wraps, 100 Ft. Expanding Garden Hose, Samsung Galaxy S5 Smartphones & More',
to: [ { address: '[email protected]', name: null } ],
sender: { address: '[email protected]', name: 'Groupon Goods' },
from: { address: '[email protected]', name: 'Groupon Goods' },
cc: [],
bcc: [],
attachments: [],
internaldate: 1432748540000,
uid: 20263,
list_id: '<channel-goods_us_im_feynman_SundayWednesday_20150527.groupon>',
@skabbes
skabbes / gist:538e6b0e17492d6ec992
Last active August 29, 2015 14:07
no constructor :(
@interface MBBlob : NSObject

@property (nonatomic, readonly) NSNumber *numberValue;

@property (nonatomic, readonly) NSString *stringValue;

@end
@skabbes
skabbes / gist:7780664
Created December 4, 2013 01:12
iced coffeescript -> javascript
search = (query, callback) ->
await doSearchQuery, defer searchResult
callback(null, searchResult)
@skabbes
skabbes / gist:7409493
Created November 11, 2013 07:59
How to allocate into a vector<char> in libuv?
uv_buf_t alloc_buffer(uv_handle_t * handle, size_t suggested_size) {
vector<char> * data = new vector<char>(suggested_size);
return uv_buf_init(data->data(), suggested_size);
}
void on_read(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
vector<char> * data = reinterpret_cast<vector<char> * >(buf.__data);
// do something else
delete data;
}
@skabbes
skabbes / .vimrc
Created July 28, 2012 01:35
Pretty minimal vimrc, still adding to it daily :)
set nocompatible
set history=1000
set undolevels=1000
let mapleader=","
call pathogen#infect()
" turn off swap files and backup copies, git instead
set nobackup
set noswapfile
set nowritebackup