Skip to content

Instantly share code, notes, and snippets.

private View rootView;
@Override
public View onCreateView(int resourceId, LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (rootView != null) {
ViewGroup parent = (ViewGroup) rootView.getParent();
if (parent == null) {
parent = container;
}
parent.removeView(rootView);
private void printKeyHash() {
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
# Problem 1
plussum <- function(v){
r <- 0
for(i in 1:length(v)){
r <- r + if(v[i] > 0 ) v[i] else 0
}
return(r)
}
# test inputs for prob 1
# Problem 1
f1 <- function(n, k){
# initialize an nxn matrix with empty elements
mat <- matrix(ncol = n, nrow = n)
# evealuate the indices i and j
for(i in 1:nrow(mat)){
for(j in 1:ncol(mat)){
# assign values
mat[i, j] = if(i == j) k else if(j == i +1 || i == j + 1) 1 else 0
}
f3 <- function(m){
for(i in 1:nrow(m)){
for(j in 1:ncol(m)){
m[i,j] = if(m[i,j] %% 2 != 0) m[i,j]*2 else m[i,j]
}
}
return(m)
}
N <- matrix(c(c(1,5,-2),c(1,2,-1),c(3,6,-3)), ncol = 3, nrow = 3)
print(N)

Keybase proof

I hereby claim:

  • I am kebbbnnn on github.
  • I am kbn (https://keybase.io/kbn) on keybase.
  • I have a public key whose fingerprint is 1F63 2DFC 329F FC64 29BD CFDD D2D8 1A3F 1A1F 21AD

To claim this, I am signing this object:

@kebbbnnn
kebbbnnn / PaletteWithPicasso
Last active August 29, 2015 14:13
code snippet in getting the primary and primary dark colors when using picasso
private int colorPrimary;
private int colorPrimaryDark;
Picasso.with(context).load(URL).into(new Target() {
@Override
public void
onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
imageView.setImageBitmap(bitmap);
Palette palette = Palette.generate(bitmap);
colorPrimary = palette.getLightVibrantSwatch().getRgb();