Skip to content

Instantly share code, notes, and snippets.

View joncode's full-sized avatar
🏠
Working from home

Jon Gutwillig joncode

🏠
Working from home
View GitHub Profile
@joncode
joncode / gist:57348319ccf051a2fe3b24d511a50008
Last active September 2, 2022 03:52
COPY FROM s3 to s3 DIFFERENT ACCOUNTS
from https://blogs.tensult.com/2018/08/06/copy-s3-bucket-objects-across-aws-accounts/
In this blog, I am going to explain about, how to transfer S3 objects from one AWS account to another.
Prerequisites
Two AWS accounts(One for source S3 bucket and another for destination S3 bucket)
Create an IAM user in destination AWS account (see this doc to create IAM user for AWS account).
Configure AWS CLI in local machine with previously created IAM user credentials (see this doc to configure AWS CLI).
Step 1: Get The 12 Digit Destination AWS Account Number
Sign in to destination AWS account. Go to Support → Support center and copy account number from there.
@joncode
joncode / SaveAudioBufferToWavFile.cpp
Created March 15, 2021 05:38 — forked from ruben44100/SaveAudioBufferToWavFile.cpp
JUCE, save AudioBuffer to Wav file
AudioBuffer<float> buffer;
buffer.setSize(2, 10000);
// do something with buffer
File file("D:/test.wav");
file.deleteFile();
WavAudioFormat format;
std::unique_ptr<AudioFormatWriter> writer;
@joncode
joncode / gist:a34fdd0ee1ab2c1d4fc7
Created December 18, 2015 23:42
PrettyPrint JSON
pp(JSON.parse(object.to_json))
General
\copyright show PostgreSQL usage and distribution terms
\g [FILE] or ; execute query (and send results to file or |pipe)
\gset [PREFIX] execute query and store results in psql variables
\h [NAME] help on syntax of SQL commands, * for all commands
\q quit psql
\watch [SEC] execute query every SEC seconds
Query Buffer
\e [FILE] [LINE] edit the query buffer (or file) with external editor
@joncode
joncode / gist:a228feb2e6e31b247611
Created February 18, 2015 13:28
KILL UNIX Server
list the pids
lsof -i:3000
ruby 28479 username 10u IPv4 0x50e2b32487dea405 0t0 TCP *:hbci (LISTEN)
kill the server
kill -9 28479
@joncode
joncode / gist:b5a8a3db4d1e30f94398
Created November 28, 2014 19:05
ios randomize - choose one or other randomly
message.sentByString = arc4random_uniform(2) == 0 ? [LGChatMessage SentByOpponentString] : [LGChatMessage SentByUserString];
@joncode
joncode / gist:3b41bb5c779df45febd1
Created November 21, 2014 18:54
How to locate a deleted file in the commit history? git
http://stackoverflow.com/questions/7203515/how-to-locate-a-deleted-file-in-the-commit-history/21871377#21871377
@joncode
joncode / gist:6f7be4ab8d19a1e994f1
Created October 10, 2014 18:25
Useful Rails API methods

ApplicationController.included_modules

ApplicationController.ancestors - ApplicationController.included_modules

HelpsController.action(:index) #=> returns a proc rack application - plus the line of the source code metal.rb:230 #Proc:0x007fcfad287a38@/Users/jongutwillig/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.0/lib/action_controller/metal.rb:230 HelpsController.method(:action).source_location #=> where it is defined ["/Users/jongutwillig/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.0/lib/action_controller/metal.rb", 229]

There are TWO MIDDLEWARE STACKS ! - one for the app - one for controller lookup

@joncode
joncode / gist:354fdec19a2a18feb11b
Created September 9, 2014 17:32
Launching a dev resque server
run the redis server
1. in the command line
redis-server
2. start the rails server
rs
3. start the resque rake task
QUEUE=* rake resque:work
@joncode
joncode / gist:b5232631d8227c3ab7d0
Last active August 29, 2015 14:05
Heroku Platform-api commands
heroku = PlatformAPI.connect_oauth('f04asdfbd-18e5-4486-b4df-873asdfa')
heroku.app.info('dbappdev')
heroku.formation.list('dbappdev')
heroku.dyno.list('dbappdev')
heroku.dyno.info('dbappdev', dyno_id)