Skip to content

Instantly share code, notes, and snippets.

View mjjimenez's full-sized avatar

Mark Jimenez mjjimenez

View GitHub Profile
@mjjimenez
mjjimenez / gist:129888bb656bae5dc308d6399a9c7302
Last active October 21, 2021 20:40
Springboard questions
[
{
"questionId": "C614B380-8DF9-11EA-AB12-0800200C9A66",
"question": "You want to be able to store application logs from your Kubernetes Cluster for more than a year to be able to analyze them and monitor frequency errors. What is your best option to stream and store logs?",
"subQuestion": "",
"domain": "cdmp-gcp-simulated-exam",
"difficulty": "medium",
"answers": {
"a": "Configure Cloud Logging for your cluster and do nothing because logs are stored forever.",
"b": "Use pubsub to send the logs to a subscriber and process them using DataProc",
torch::jit::script::Module forwardModel = torch::jit::load(forwardFilePath.UTF8String);
torch::jit::script::Module backwardModel = torch::jit::load(backwardFilePath.UTF8String);
auto w = torch::IValue(torch::full({10}, 1.0f));
torch::IValue loss;
//Create train x
std::vector<torch::jit::IValue> train_x;
for (int i = 0; i < 500; i++) {
train_x.push_back(torch::rand({10}));
@mjjimenez
mjjimenez / ec2_xgboost_install.sh
Last active October 24, 2019 02:54
Install xgboost on ec2 instance
# From 'Manuel Amunategui' https://www.youtube.com/watch?v=VncfC5GeqGs
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
pip install --upgrade pip
pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
sudo yum groupinstall -y 'Development Tools'
@mjjimenez
mjjimenez / AnimatedScroll.m
Created December 15, 2013 00:45
Animate scrolling to new content offset when keyboard appears in iOS 7.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
[UIView setAnimationCurve:[info[UIKeyboardAnimationCurveUserInfoKey] integerValue]];
[UIView setAnimationBeginsFromCurrentState:YES];
self.textViewKeyboardConstraint.constant = height;
UIEdgeInsets insets = UIEdgeInsetsMake(
scrollView.contentInset.top, 0, textView.bounds.size.height + height, 0);
scrollView.contentInset = insets;
scrollView.scrollIndicatorInsets = insets;
@mjjimenez
mjjimenez / ScrollViewController.m
Created December 14, 2013 09:21
Autoscroll of UIScrollView
// Call this method somewhere in your view controller setup code.
- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
@mjjimenez
mjjimenez / TableViewController.m
Created December 14, 2013 09:04
Autoscroll of TableView when not using TableViewController http://kingscocoa.com/tutorials/keyboard-content-offset/
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
@mjjimenez
mjjimenez / UIView+StringTagAdditions.h
Created December 14, 2013 06:57
Add string type tag to UIViews
#import <UIKit/UIKit.h>
@interface UIView (StringTagAdditions)
@property (nonatomic, copy) NSString *stringTag;
@end
@mjjimenez
mjjimenez / transparent_background_view.m
Created December 8, 2013 12:58
Transparent background view
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
@mjjimenez
mjjimenez / UIImage+Transform.h
Created December 4, 2013 04:36
UIImage category for resizing and rotating methods. Made by http://www.catamount.com/forums/viewtopic.php?f=21&t=967
#import <UIKit/UIKit.h>
@interface UIImage (Transform)
- (UIImage *)imageAtRect:(CGRect)rect;
- (UIImage *)imageByScalingProportionallyToMinimumSize:(CGSize)targetSize;
- (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize;
- (UIImage *)imageByScalingToSize:(CGSize)targetSize;
- (UIImage *)imageRotatedByRadians:(CGFloat)radians;
@mjjimenez
mjjimenez / weak_self
Created November 29, 2013 11:32
Weak self reference
__weak typeof(self) weakSelf = self;