Skip to content

Instantly share code, notes, and snippets.

View photizzo's full-sized avatar

Ememobong Akpanekpo photizzo

View GitHub Profile
@photizzo
photizzo / O'Reilly Design Books (Free).md
Created July 4, 2017 14:09 — forked from udezekene/O'Reilly Design Books (Free).md
Download the just released O'Reilly Design Books for free without e-mail signup.

Free O'Reilly Design Books and convenient script to just download them.

HUGE thanks to O'Reilly for making this resource free. Visit the design page if you want to learn more about the design resources. Also, they do have FREE resources for other topics like: Data, IoT, Programming, Security, Web Development, and WebOps.

Thanks @augbog for the initial gist. If you are a developer or looking for software engineering books, headover to the source of this fork.

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
import numpy as np
a = (np.random.rand(1,10)) #create a random (1,10) array
result = np.zeros(10) #create an array of zeros to hold the result
result = (b.reshape(1,10))# reshape b to make sure its a (1,10) array and not (10,)
print ("a: \n" + str(a))
for i in range(10):
if a[0,i]>0.5:
result[0,i] = 1
else:
result[0,i] = 0
import numpy as np
a = (np.random.rand(1,10)) #create a random (1,10) array
print ("a: \n" + str(a))
result = (np.where(a>0.5,1,0))
print ("result: \n" +str(result))
a:
[[ 0.76456104 0.75182292 0.11825977 0.97635566 0.3220488 0.44064402
0.08142387 0.65055208 0.88407891 0.40323535]]
result:
[[1 1 0 1 0 0 0 1 1 0]]
import numpy as np
array = [[True, False], [True, True]] # (2,2) array of boolean values
array_cond_true = [[1, 2], [3, 4]] # (2,2) array of where to pick values if array at position is true
array_cond_false = [[9, 8], [7, 6]] # (2,2) array of where to pick values if array at position is false
print ("result: \n" + str(np.where(array,
array_cond_true,
array_cond_false)))
result:
[[1 8]
[3 4]]
import numpy as np
import time
a = (np.random.rand(1,1000000)) #create a random (1,10) array
result1 = np.zeros((1,1000000),dtype=np.int) #create an array of zeros to hold the result
#print ("a: \n" + str(a))
tic = time.time()
for i in range(1000000):
if a[0,i]>0.5:
result1[0,i] = 1
else:
time passed for result1: 1.2310867309570312ms
time passed for result2: 0.014905214309692383ms
package com.rideon.user.activities;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;