Skip to content

Instantly share code, notes, and snippets.

View NickShargan's full-sized avatar

Mykola Sharhan NickShargan

  • Canada, Toronto
View GitHub Profile
@certik
certik / compile_run.sh
Last active February 23, 2023 22:50
Test offscreen rendering with VTK 6
#! /bin/bash
set -e
g++ -o test_offscreen.o -c test_offscreen.cpp -I$PYTHONHPC/include/vtk-6.0
g++ -o test_offscreen test_offscreen.o $PYTHONHPC/lib/libvtk*.so
LD_LIBRARY_PATH=$PYTHONHPC/lib/ ./test_offscreen
@mmechtley
mmechtley / shuffle.py
Created July 10, 2013 06:02
Numpy shuffled axis example
import numpy as np
arr = np.arange(100).reshape(4,5,5)
indexes = np.arange(5)
np.random.shuffle(indexes)
dim2shuff = arr[:,indexes,:]
dim3shuff = arr[:,:,indexes]
@mabdrabo
mabdrabo / sound_recorder.py
Created January 28, 2014 23:05
Simple script to record sound from the microphone, dependencies: easy_install pyaudio
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@teeks99
teeks99 / boost.python-quickstart.md
Last active March 15, 2017 15:04
Boost Python Quickstart Example - Getting it working

I wasn't able to get the basic quickstart example for Boost.Python working without some modifications, so I wanted to document it for others.

Here are the various issues I encountered with the default example:

  • The Bjam file (in the root of boost or in the quickstart, i'm not sure) defaults to threading=single, but something else is defaulting to threading=multi, so they are incompatible (shows up as saying the boost_python-vcXXX-mt-gd-1_XX.lib is not found when it just generated boost_python-vcXXX-gd-1_XX.lib). Manually specifying threading=multi for the bjam commands seems to fix things.
  • I wanted to get this going with boost 1.57.0, but there was a change to the boost::build directory structure in 1.56+ that hasn't been reflected in the quickstarts boost-build.jam file, so I reverted back to 1.55.0.
  • Visual Studio 2010 (msvc-10.0) has a bug that keeps it
@RobertoSchneiders
RobertoSchneiders / elasticbeanstalk_deploy_iam_policy.md
Last active May 28, 2024 23:07
IAM Policy for deploy on Elastic Beanstalk

I am deploying with this IAM using Codeship and Circle CI to Elastic Beanstalk. I had a lot of trouble with this config. I talked to the aws support for about 6 hours until this worked properly, so, I guess it is worth to share.

UPDATE: In the end, I have to use the AWSElasticBeanstalkFullAccess policy. My custom policy keep breaking every week with some new added permission or some EB internal change. Anyway, the IAM I was using is below.

This works for me with CircleCI and EB Cli.

{
    "Version": "2012-10-17",
    "Statement": [
        {
@baraldilorenzo
baraldilorenzo / readme.md
Last active June 13, 2024 03:07
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@IamAdiSri
IamAdiSri / Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Last active May 9, 2022 22:08 — forked from evansneath/Python3 Virtualenv Setup
Setting up and using Python3, Pip3, Virtualenv (for Python3) and Virtualenvwrapper (for Python3)
First install pip for Python2. Download the get-pip.py file from https://bootstrap.pypa.io/get-pip.py
$ cd <download location>
$ sudo -H python ./get-pip.py
Installing pip also installs Python3
To run Python3
$ python3
Install pip3 by just executing the same file as in the step above, but this time using Python3
$ sudo -H python3 ./get-pip.py
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@wassname
wassname / dice_loss_for_keras.py
Created September 26, 2016 08:32
dice_loss_for_keras
"""
Here is a dice loss for keras which is smoothed to approximate a linear (L1) loss.
It ranges from 1 to 0 (no error), and returns results similar to binary crossentropy
"""
# define custom loss and metric functions
from keras import backend as K
def dice_coef(y_true, y_pred, smooth=1):