Skip to content

Instantly share code, notes, and snippets.

View haseebpvt's full-sized avatar
🏳️
Hala Madrid

Haseeb haseebpvt

🏳️
Hala Madrid
View GitHub Profile
@haseebpvt
haseebpvt / about.txt
Created April 10, 2019 22:52
Something
Hey there
@haseebpvt
haseebpvt / Celsius_to_Fahrenheit_conversion_with_tensorflow.py
Created May 18, 2019 08:39
Celsius to Fahrenheit conversion with Tesorflow
# F = C * 1.8 + 32
print('The program starts')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
import numpy as np
import matplotlib.pyplot as plt
@haseebpvt
haseebpvt / custom_dialog_fragment.xml
Created May 27, 2019 15:13
XML Layout for material dialog fragment in android
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minWidth="280dp"
app:cardCornerRadius="20dp">
@haseebpvt
haseebpvt / AnimatorSetExample.txt
Created May 27, 2019 15:48
Animation In Android using Animator set
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
ObjectAnimator.ofFloat(image,"translationY",-1000,0),
ObjectAnimator.ofFloat(image,"alpha",0,1),
ObjectAnimator.ofFloat(text,"translationX",-200,0)
);
animatorSet.setInterpolator(new DescelerateInterpolator());
animatorSet.setDuration(2000);
animatorSet.addListener(new AnimatorListenerAdapter(){
@Override public void onAnimationEnd(Animator animation) {
@haseebpvt
haseebpvt / dpToPixel.java
Created June 7, 2019 22:02
Method to convert DP to pixel
public static int convertDip2Pixels(Context context, int dip) {
return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, context.getResources().getDisplayMetrics());
}
@haseebpvt
haseebpvt / app.js
Last active July 18, 2019 08:27
Writing to firebase with Node.js
//Install firebase admin
//npm install firebase-admin --save
//Get generated key and place it in the working directory
//Replace line 7 file name with yours
var firebase = require("firebase-admin");
var serviceAccount = require("./service_accountKey.json");
@haseebpvt
haseebpvt / app.js
Created November 18, 2019 14:46
Code for cors error
//var express = require('express');
//var app = express();
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', "Origin, X-Requested-With, Content-Type, Accept, Authorization");
if (req.method === 'OPTIONS') {
res.header('Access-Control-Allow-Method', 'PUT, POST, PATCH, DELETE, GET');
return res.status(200).json({});
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/linearLayout"
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class EasyLogger {
private static StringBuilder sb;
/**
* A way to log all around application
public class Helpers {
final protected static char[] hexArray = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
int v;
for (int j = 0; j < bytes.length; j++) {
v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];