Skip to content

Instantly share code, notes, and snippets.

View gulshan's full-sized avatar

Gulshan gulshan

  • Dhaka, Bangladesh
View GitHub Profile
@gulshan
gulshan / webhook.d.ts
Created March 19, 2020 15:44
Facebook Messenger Webhook
/**
* Types for Webhook interface.
* (see https://developers.facebook.com/docs/messenger-platform/webhook-reference)
*/
export interface Request {
object: "page";
entry: MessageEntry[];
}
export interface MessageEntry {
@gulshan
gulshan / loadImagefromUrlAsync.kt
Last active December 23, 2023 06:29
Kotlin async task helper and ImageView load image from url using the helper.
inline fun runAsync(crossinline action: () -> Unit): AsyncTask<Unit, Unit, Unit> =
object : AsyncTask<Unit, Unit, Unit>() {
override fun doInBackground(vararg params: Unit?) = action()
}.also { it.execute() }
fun ImageView.loadImageFromUrl(imageUrl: String) {
runAsync {
runCatching {
val bitmap = URL(imageUrl).openStream().use { BitmapFactory.decodeStream(it) }
post { setImageBitmap(bitmap) }
@gulshan
gulshan / PageAdapter.kt
Created August 18, 2019 07:25
Android ViewPager without fragments. Set and object of this class as adapter of the viewPager.
class PageAdapter : PagerAdapter() {
private val pageLayouts = listOf(R.layout.home_page_1, R.layout.home_page_2)
override fun instantiateItem(container: ViewGroup, position: Int): Any =
LayoutInflater.from(container.context).inflate(pageLayouts[position], container, false).apply {
container.addView(this)
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) =
container.removeView(`object` as View)
@gulshan
gulshan / Initial_work_list_csharp_7.md
Created February 10, 2017 16:04
This is a list of features we have looked at for C# 7

This is a list of features we have looked at for C# 7, roughly categorized according to our current level of interest and estimated plausibility.

Please don't infer anything about the final shape of C# 7 (or future versions). The list is a tracking mechanism for work, not a description of the outcome. We have a long way to go yet!

Each bucket is in no particular order. I'll try to think of a more systematic way of cross-referencing with proposals and notes, but wanted to get the list out there.

I'll keep the list updated as we look at more feature ideas and change our minds about the relative importance.

Strong interest

using System.Collections.Generic;
enum TargetFramework
{
Netstandard11,
Netstandard14,
Netstandard16,
Netstandard20
}
var travelled = 0f;
var length = 100f; //cm
var time = 0L; //sec
var inc = 16;
while(length > travelled)
{
time++;
travelled++;
length += inc;
@gulshan
gulshan / csproj.xml
Created October 20, 2016 05:31
csproj without PropertyGroup and ItemGroup
<Project>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<Compile Include="**\*.cs" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.SDK" Version="1.0.0" />