Skip to content

Instantly share code, notes, and snippets.

View vetional's full-sized avatar

Prateek Shrivastava vetional

  • Amazon
  • Hydrabad
  • 19:49 (UTC +05:30)
View GitHub Profile

###SSH into a remote machine###

ssh [email protected]
#or by ip address
ssh [email protected]

exit: exit ###Install Something###

#If it's a new server, update apt-get first thing
@vetional
vetional / one-hot.py
Created May 15, 2016 14:35 — forked from ramhiser/one-hot.py
Apply one-hot encoding to a pandas DataFrame
import pandas as pd
import numpy as np
from sklearn.feature_extraction import DictVectorizer
def encode_onehot(df, cols):
"""
One-hot encoding is applied to columns specified in a pandas DataFrame.
Modified from: https://gist.github.com/kljensen/5452382
#!/bin/bash
# setup python dev
sudo apt-get install build-essential git make libncurses-dev zip libfreetype6-dev libxft-dev python-pip python-dev python-virtualenv libssl-dev libffi-dev python-matplotlib
wget http://repo.continuum.io/archive/Anaconda2-4.1.0-Linux-x86_64.sh
bash ~/Anaconda3-4.0.0-Linux-x86_64.sh
echo "boto==2.39.0
#!/bin/bash
# Copyright 2015 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@vetional
vetional / beautiful_idiomatic_python.md
Created July 24, 2016 10:04 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@vetional
vetional / tensorflow_gpu.sh
Last active July 28, 2016 14:58
Setup tensorflow on ubuntu with GPU support
# Install build tools
sudo apt-get update
sudo apt-get install -y build-essential git python-pip curl software-properties-common libfreetype6-dev libxft-dev libncurses-dev libopenblas-dev gfortran python3-matplotlib libblas-dev liblapack-dev libatlas-base-dev python3-dev linux-headers-generic linux-image-extra-virtual unzip python3-numpy swig python3-pandas python-sklearn unzip python3-pip
# Install CUDA 7
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1410/x86_64/cuda-repo-ubuntu1410_7.0-28_amd64.deb
# wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1504/x86_64/cuda-repo-ubuntu1504_7.5-18_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1504_7.0-28_amd64.deb
sudo apt-get update
sudo apt-get install -y cuda
@vetional
vetional / percent.c
Last active August 24, 2016 16:00 — forked from anonymous/percent.c
#ifdef __ANDROID__
#include "jni.h"
#include "android/log.h"
#define LOG_TAG "psx"
#define PRINTMSGS(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@vetional
vetional / utility.sh
Last active May 16, 2017 14:08
docker utility commands
wget -qO- https://get.docker.com/ | sh
sudo apt-get update
sudo apt-get install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
@vetional
vetional / Max slice.py
Created October 6, 2017 05:43
Max slice created by vetional - https://repl.it/MLrd/0
from functools import reduce
def golden_max_slice(A):
max_ending = max_slice = 0
if all(a > 0 for a in A):
return reduce((lambda x, y: x + y), A)
if all(a < 0 for a in A):
return max(A)
@vetional
vetional / Prefix sum (mashroom).py
Created October 6, 2017 14:09
Prefix sum (mashroom) created by vetional - https://repl.it/MNNH/0
'''
Problem:
You are given a non-empty, zero-indexed array A of n (1 ¬ n ¬ 100 000) integers a0, a1, . . . , an−1 (0 ¬ ai ¬ 1 000). This array represents number of mushrooms growing on the consecutive spots along a road. You are also given integers k and m (0 ¬ k, m < n).
A mushroom picker is at spot number k on the road and should perform m moves. In
one move she moves to an adjacent spot. She collects all the mushrooms growing on spots she visits. The goal is to calculate the maximum number of mushrooms that the mushroom picker can collect in m moves.
'''
import math