Skip to content

Instantly share code, notes, and snippets.

View ishaquehassan's full-sized avatar
🎯
I may be slow to respond.

Ishaq Hassan ishaquehassan

🎯
I may be slow to respond.
View GitHub Profile
@ishaquehassan
ishaquehassan / consoleWriteLine.java
Created March 27, 2017 15:57
A Simple Method to make System.out.println() works like C#'s Console.writeLine()
public static void consoleWriteLine(String message, Object... data){
if(message.contains("{0}") && data.length > 0){
int di = 0;
for(Object o : data){
message = message.replace("{"+di+"}",String.valueOf(o));
di++;
}
}
System.out.println(message);
}
@ishaquehassan
ishaquehassan / Message.java
Created August 15, 2017 15:24
A Simple chat messages model for Android Native using JAVA
package com.cyberavanza.chat.model;
import android.view.View;
/**
* Created by Ishaq Hassan
*/
public class Message {
int id;
fun MyClass.hello(){
}
fun main(args: Array<String>) {
val myObj = MyClass("Ishaq",10,"34343434")
myObj.phone
myObj.hello()
compileKotlin2Js.kotlinOptions {
moduleKind = "commonjs"
outputFile = "functions/index.js"
}
cd functions && npm install kotlin --save && cd ..
external fun require(module:String) : dynamic
external var exports: dynamic
fun main(args: Array<String>) {
val fireFunctions = require("firebase-functions")
exports.myTestFun = fireFunctions.https.onRequest { request , response ->
response.send("Hi from kotlin!")
}
}
@ishaquehassan
ishaquehassan / RecyclerGeneralTypeAdapter
Last active January 17, 2019 14:28
A RecyclerView Adapter for general purpose simple lists. It supports all common features including itemViewType.
package com.ishaquehassan.recyclerviewgeneraladapter
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
class RecyclerGeneralTypeAdapter<T>(val data:ArrayList<T>, private val layoutFiles:Map<Int,Int>, val onGetViewType:(Int, T)->Int, val onBindItem:(itemData:T, viewHolder:RecyclerGeneralTypeAdapter<T>.RecyclerGeneralViewHolder)->Unit) : RecyclerView.Adapter<RecyclerGeneralTypeAdapter<T>.RecyclerGeneralViewHolder>(){
constructor(data:ArrayList<T>,layoutFile: Int,onBindItem:(T,RecyclerGeneralTypeAdapter<T>.RecyclerGeneralViewHolder)->Unit):this(data, mapOf(-10 to layoutFile),{_,_->-10},onBindItem)
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Map;
public class MyThreadsApp {
public static void main (String [] args)
{
Thread currentThread = Thread.currentThread();
System.out.println(currentThread);
MyThread mt1 = new MyThread ();
mt1.setName("MyThread1");
import 'package:http/http.dart' as http;
class Api{
static final String BASE_URL = "http://yourserver.com";
static final String API_KEY = "YOUR_KEY";
static String fcmTOKEN = "YOUR_TOKEN";
Future<http.Response> getRequest(String endPoint){
return http.get(BASE_URL+"/"+endPoint, headers: {
"apikey": API_KEY