Skip to content

Instantly share code, notes, and snippets.

View AlexJuca's full-sized avatar
:atom:
Investigating

Alexandre Antonio Juca AlexJuca

:atom:
Investigating
  • Currently a Software Engineer at Yoco
  • Portugal
  • X @0xFFA4
View GitHub Profile
@AlexJuca
AlexJuca / Alex
Created April 25, 2015 20:35
The worst code ever
,;lskdla;dlka;lsd,adasd
public static void findStudent(int key, int[] studentList) {
int N = studentList.length;
for(int i = 0; i < N; i++) {
if(studentList[i] == key) {
System.out.println("Key has been found");
} else System.out.println(" Key was not found ");
}
}
@AlexJuca
AlexJuca / gist:322d1d95ee7c5b677c8a
Created December 27, 2015 14:39
timedLinearSearch
public static void findStudent(int key, int[] studentList) {
final long startTime = System.nanoTime();
int N = studentList.length;
for(int i = 0; i < N; i++) {
if(studentList[i] == key) {
System.out.println("Key has been found");
} else System.out.println(" Key was not found ");
}
final long endTime = System.nanoTime();
public static int binarySearch(int key, int[] largeList) {
int lo = 0;
int hi = largeList.length - 1;
while(lo <= hi) {
int mid = (lo + hi) / 2;
if(key < largeList[mid]) hi = mid - 1;
else if (key > largeList[mid]) lo = mid + 1;
else return mid;
}
return -1;
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
@AlexJuca
AlexJuca / RAILS_CHEATSHEET.md
Created December 29, 2017 17:50 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@AlexJuca
AlexJuca / missing_data.py
Last active January 16, 2018 23:18
pandas dataset with empty cells
import numpy as np
import pandas as pd
# Create a dictionary that we used to create our pandas DataFrame
fake_dataset = {'Price':[1000,2109, np.nan], 'Size':[55,np.nan, 75], 'N of Rooms':[3, 2, 5]}
pd = pd.DataFrame(fake_dataset)
pd.dropna()
pd.dropna(axis=1)
@AlexJuca
AlexJuca / System Design.md
Created May 25, 2018 22:44 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
class UserProfileViewModel: ViewModel {
var userProfileData: MutableLiveData<User>? = null
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_profile)
mViewModel = ViewModelProviders.of(this).get(UserProfileViewModel.class);
// Other setup code below...
}