Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Shahbaz Ahmed shahbazahmed1269

🎯
Focusing
View GitHub Profile
View standard-dev-outliers.py
import numpy
arr = [10, 386, 479, 627, 20, 523, 482, 483, 542, 699, 535, 617, 577, 471, 615, 583, 441, 562, 563, 527, 453, 530, 433, 541, 585, 704, 443, 569, 430, 637, 331, 511, 552, 496, 484, 566, 554, 472, 335, 440, 579, 341, 545, 615, 548, 604, 439, 556, 442, 461, 624, 611, 444, 578, 405, 487, 490, 496, 398, 512, 422, 455, 449, 432, 607, 679, 434, 597, 639, 565, 415, 486, 668, 414, 665, 763, 557, 304, 404, 454, 689, 610, 483, 441, 657, 590, 492, 476, 437, 483, 529, 363, 711, 543]
elements = numpy.array(arr)
mean = numpy.mean(elements, axis=0)
sd = numpy.std(elements, axis=0)
final_list = [x for x in arr if (x > mean - 2 * sd)]
@shahbazahmed1269
shahbazahmed1269 / blink1.py
Created Apr 7, 2018
Raspberry Pi GPIO LED blink
View blink1.py
from gpiozero import LED
from time import sleep
led = LED(25)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
View gist:ba1a5cab9552de0f48b25b7ac5d71b0f
# Edit ~/.bash_profile
export GOPATH=/Users/username/go
export PATH=$GOPATH/bin:$PATH
# Reload profile : source ~/.bash_profile
@shahbazahmed1269
shahbazahmed1269 / MainActivityNew.java
Last active Sep 21, 2017
Part of my 2nd blog post on architecture components and MVVM
View MainActivityNew.java
public class MainActivity extends AppCompatActivity {
@Inject
ViewModelProvider.Factory mViewModelFactory;
// Other fields
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@shahbazahmed1269
shahbazahmed1269 / IssuesApplication.java
Created Jun 10, 2017
Part of my 2nd blog post on architecture components and MVVM
View IssuesApplication.java
public class IssuesApplication extends Application {
AppComponent mAppComponent;
@Override
public void onCreate() {
super.onCreate();
mAppComponent = DaggerAppComponent.builder().build();
}
public AppComponent getAppComponent() {
return mAppComponent;
@shahbazahmed1269
shahbazahmed1269 / ViewModelFactory.java
Created Jun 10, 2017
Part of my 2nd blog post on architecture components and MVVM
View ViewModelFactory.java
public class ViewModelFactory implements ViewModelProvider.Factory {
private ListIssuesViewModel mViewModel;
@Inject
public ViewModelFactory(ListIssuesViewModel viewModel) {
this.mViewModel = viewModel;
}
@Override
public <T extends ViewModel> T create(Class<T> modelClass) {
@shahbazahmed1269
shahbazahmed1269 / ListIssuesViewModelSample.java
Created Jun 10, 2017
Part of my 2nd blog post on architecture components and MVVM
View ListIssuesViewModelSample.java
public class ListIssuesViewModel extends ViewModel {
private MediatorLiveData<ApiResponse> mApiResponse;
private IssueRepository mIssueRepository;
@Inject
public ListIssuesViewModel(IssueRepository issueRepository) {
mApiResponse = new MediatorLiveData<>();
mIssueRepository = issueRepository;
}
@shahbazahmed1269
shahbazahmed1269 / IssueRepositoryImplSample.java
Created Jun 10, 2017
Part of my 2nd blog post on architecture components and MVVM
View IssueRepositoryImplSample.java
public class IssueRepositoryImpl implements IssueRepository {
@Inject
GithubApiService mApiService;
@Inject
public IssueRepositoryImpl() {
}
// Other code remains unchanged ...
}
@shahbazahmed1269
shahbazahmed1269 / AppComponent.java
Created Jun 10, 2017
Part of my 2nd blog post on architecture components and MVVM
View AppComponent.java
@Component(modules = {AppModule.class})
public interface AppComponent {
void inject(MainActivity mainActivity);
}
@shahbazahmed1269
shahbazahmed1269 / AppModule.java
Created Jun 10, 2017
Part of my 2nd blog post on architecture components and MVVM
View AppModule.java
@Module
public class AppModule {
public static final String BASE_URL = "https://api.github.com/";
@Provides
@Singleton
GithubApiService provideGithubApiService() {
return new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
You can’t perform that action at this time.