Skip to content

Instantly share code, notes, and snippets.

View afrinjamanbd's full-sized avatar
🔆
Google Summer of Code Winner 2019

Afrin Jaman afrinjamanbd

🔆
Google Summer of Code Winner 2019
View GitHub Profile
@afrinjamanbd
afrinjamanbd / newActivityFromSearchView.md
Created January 21, 2019 16:34 — forked from vxhviet/newActivityFromSearchView.md
Start new activity from SearchView

Source: StackOverflow

This answer is a little late but I feel it'll be useful for future viewers. The dilemma seems to come from the ambiguity of the Android SearchView tutorial. The scenario they cover assumes you will be displaying the results in the same Activity the SearchView resides. In such a scenario, the Activity tag in the AndroidManifest.xml file would look something like this:

<activity
    android:name=".MainActivity"
    android:label="@string/main_activity_label"
    android:launchMode="singleTop">
        <intent-filter>
package com.mako.companyname;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@afrinjamanbd
afrinjamanbd / Inheritancegolang.go
Created January 20, 2021 11:13
This piece of code shows inheritance in golang.
package main
import (
"fmt"
)
type Animal struct{
Name string
Tail bool
Leg int
@afrinjamanbd
afrinjamanbd / FuncChanining.py
Created January 20, 2021 15:41
A builder design pattern or chaining in Python
class Calculator:
total = 0
def add(self, number):
self.total = self.total + number
return self
def remove(self, number):
self.total = self.total - number
return self
@afrinjamanbd
afrinjamanbd / Chaining.go
Created January 20, 2021 16:22
A builder design pattern or chaining in Golang.
package main
import (
"fmt"
)
type Calculator struct{
total int
}
@afrinjamanbd
afrinjamanbd / PythonCheatSheet.py
Created February 5, 2021 04:41
Python Cheat Sheet
course = 'my name is afrin'
print(f'hi {course[:7]} and {course[3:-4]} or {course[5:7]}')
print(len(course[2:5]))
print(course.upper())
print(course.lower())
print(course.find('n'))
print(course.find('y name'))
print(course.find('no'))
print(course.replace('my', 'her'))
if 'my' in course:
@afrinjamanbd
afrinjamanbd / goCheatSheet.go
Last active February 6, 2021 10:17
go cheat sheet
package main
import (
"fmt"
"strconv"
"github.com/afrinjamanbd/firstapp/help"
)
var (
@afrinjamanbd
afrinjamanbd / gviz_api_django.py
Created December 2, 2021 15:11
Simple example to use gviz_api with Django Models
import gviz_api
description = {"name": ("string", "Name"),
"salary": ("number", "Salary"),
"full_time": ("boolean", "Full Time Employee")}
data = [{"name": "Mike", "salary": (10000, "$10,000"), "full_time": True},
{"name": "Jim", "salary": (800, "$800"), "full_time": False},
{"name": "Alice", "salary": (12500, "$12,500"), "full_time": True},
{"name": "Bob", "salary": (7000, "$7,000"), "full_time": True}]
@afrinjamanbd
afrinjamanbd / Multiple Request Sender.py
Created June 5, 2022 07:16
Multiple Request Sender
# import requests module
import requests
# Making a get request
response = requests.get('https://medex.com.bd/search?search=Maxpro')
# print response
print(response)
# print json content
@afrinjamanbd
afrinjamanbd / unexpected token ' in JSON at position
Created June 10, 2022 04:59
unexpected token ' in JSON at position while Json parsing
let a;
const x = `{
'quotes':
[
{
'id':1,
'quote':'Life isn’t about getting and having, it’s about giving and being.',
'author':'Kevin Kruse'
},
{