Skip to content

Instantly share code, notes, and snippets.

View anuj72's full-sized avatar
🎯
Focusing

Anuj Sachan anuj72

🎯
Focusing
View GitHub Profile
kotlin {
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
isStatic = false
}
}
CoroutineScope(IO).launch {
try {
//do your work in background
withContext(Main) {
//do your work in main thread when background task complete
}
}catch (e:HttpException){
Log.v("Exception",e.toString())
}
}
@anuj72
anuj72 / test.kt
Last active November 4, 2019 14:53
val (request, response, result) = Fuel.post(Url)
.body(Json)
.header(mapOf("Content-Type" to "application/json","Authorization" to "Bearer $Bearer" ))
.response()
when (result) {
is Result.Failure -> {
val ex = result.getException().exception
var exm=result.getException().exception.localizedMessage
return listOf(ex.toString(),"fail")
@anuj72
anuj72 / location.html
Created August 26, 2019 06:09
lat long
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
compile "org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.4"
compile 'org.jetbrains.exposed:exposed:0.8.5'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
testCompile group: 'junit', name: 'junit', version: '4.12'
CREATE DATABASE IF NOT EXISTS mytestdb;
USE mytestdb;
create table user(id int,name varchar(50),email varchar(50));
INSERT INTO `user` (`uid`, `name`, `email`) VALUES ('1', 'anuj', 'anuj@gmail.com')
INSERT INTO `user` (`uid`, `name`, `email`) VALUES ('2', 'anuj', 'anuj@gmail.com')
fun main() {
var nm=test1()
nm.name="hello"
print(nm.name)
}
class test1(){
var name:String = "";
}
fun main() {
var a:Int=10
var b = sum(22,"anuj")
print("sum is ${b.num}")
}
class sum(age: Int,name:String){
fun main() {
println("Hello World")
}
@anuj72
anuj72 / activity_register.xml
Created April 1, 2019 07:13
activity_register.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical"
android:padding="16dp">
<TextView