Skip to content

Instantly share code, notes, and snippets.

View mwshubham's full-sized avatar
✌️
Peace

ShubhAm AgaRwal mwshubham

✌️
Peace
View GitHub Profile
result = []
n = int(input())
arr = list(map(int, input().split()))
for i in range(0,2*n, 2):
result.append([arr[i],arr[i+1]])
# sort a array based on first element
result.sort(key=lambda x: x[0])
j = 0
while j < len(result)-1:
if result[j][1] >= result[j+1][0]:
@mwshubham
mwshubham / Company.kt
Created June 6, 2020 15:07
Room one to many relation
@Entity(tableName = Company.Companion.TableInfo.tableName)
data class Company(
@PrimaryKey
var _id: String = "",
var company: String = "",
var website: String = "",
var logo: String = "",
var about: String = "",
@Ignore
var members: List<Member> = emptyList()
@mwshubham
mwshubham / Android2Excel
Last active February 3, 2020 17:46
Android Kotlin generate excel sheet file example sample
private fun generateExcel() {
try {
val workbook = HSSFWorkbook()
val spreadSheet = workbook.createSheet("Sell Report")
/*Header "Sampe..."*/
val rowA = spreadSheet.createRow(0)
val cellAA = rowA.createCell(0)
cellAA.setCellValue(HSSFRichTextString("Sampe"))
cellAA.setCellStyle(
@mwshubham
mwshubham / scrape.py
Created July 22, 2018 06:12
Scape file in python
#!/usr/bin/python
import urllib
from bs4 import BeautifulSoup
for i in range(101,9851):
url = 'https://app.getpricedrop.com/detail/' + str(i) +'?utm_source=whatsapp&utm_medium=msg'
boxurl = urllib.urlopen(url).read()
soup = BeautifulSoup(boxurl)
linescoreA = soup.find("span", {"class": "wrapper-word-price"})
print linescoreA
@mwshubham
mwshubham / TransportActivity.kt
Created July 10, 2018 19:14
Demo OSM map initialization
class TransportActivity : AppCompatActivity() {
companion object {
val TAG = TransportActivity::class.simpleName
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//handle permissions first, before map is created. not depicted here
@mwshubham
mwshubham / ImageCompression
Created April 6, 2018 06:23 — forked from vipulasri/ImageCompression
Whatsapp Like Image Compression
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.media.ExifInterface;
import android.os.AsyncTask;
import android.os.Environment;
@mwshubham
mwshubham / xmpp_file_transfer_manager
Created February 20, 2018 08:43
Xmpp File transfer manager
@Deprecated("Using different methodology to send file")
fun sendFile(userId: EntityFullJid, file: File, description: String) {
mThreadHandler.post({ mConnection?.sendFile(userId, file, description) })
}
private fun setUpFileTransferManager() {
val fileTransferManager = FileTransferManager.getInstanceFor(xmppTcpConnection)
fileTransferManager.addFileTransferListener(this)
@mwshubham
mwshubham / kotlin_realm_rv_adapter_auto_update_demo.kt
Last active November 7, 2021 11:23
RealmRecyclerViewAdapter example in kotlin using Realm Results and autoUpdate property
class HomeListAdapter(val context: Context, contactBeans: RealmResults<ContactBean>?, val realmInstance: Realm, autoUpdate: Boolean)
: RealmRecyclerViewAdapter<ContactBean, HomeListAdapter.ViewHolder>(contactBeans, autoUpdate) {
val TAG = HomeListAdapter::class.simpleName
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.item_chat, parent, false)
return ViewHolder(view)
}
@mwshubham
mwshubham / filterRegex
Last active October 16, 2017 12:43
[UPDATED] FILTER CONFIGRATION VIA TAG
^(?!(InputMethodManager|SurfaceView|SettingsInterface|SettingsInterface|NativeCrypto|System.out|libc-netbsd|Posix|WindowClient|ViewRootImpl|Surface|GraphicBuffer|Camera-JNI|FA|ActivityThread|View|CameraFramework|OpenSSLLib|skia|Bitmap|[MALI][Gralloc]|AudioTrack|AudioSystem|IJKMEDIA|J4A|art|System|MiniThumbFile|PhoneWindow|MediaStore|IInputConnectionWrapper|OpenGLRenderer|SQLiteDatabase|[MALI][Gralloc]|mali_winsys|NativeCrypto|ProgramBinary|RenderScript))
@mwshubham
mwshubham / customized_state_animator.xml
Created October 12, 2017 20:03
Android Depressed Button Style
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_pressed="true">
<set>
<objectAnimator android:duration="100" android:propertyName="translationZ" android:valueTo="4dp" android:valueType="floatType" />
</set>
</item>
<!-- base state -->
<item android:state_enabled="true">
<set>