Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Hamid hamedsj

🎯
Focusing
View GitHub Profile
@hamedsj
hamedsj / IndictableSimpleExoPlayer.kt
Last active Sep 18, 2020
IndictableSimpleExoPlayer
View IndictableSimpleExoPlayer.kt
import android.content.Context
import com.google.android.exoplayer2.DefaultLoadControl
import com.google.android.exoplayer2.DefaultRenderersFactory
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.analytics.AnalyticsCollector
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter
import com.google.android.exoplayer2.util.Clock
import com.google.android.exoplayer2.util.Util
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
@hamedsj
hamedsj / settings.py
Created May 3, 2020
Middlewares in settings.py
View settings.py
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'myapp.MyMiddleware.MyMd',
]
@hamedsj
hamedsj / MyMiddleware.py
Last active May 3, 2020
MyMiddleware.py
View MyMiddleware.py
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class MyMd(MiddlewareMixin):
def process_request(self, request):
if "p" in request.GET.keys():
return HttpResponse("Hello World =)")
return None
View views.py
from django.shortcuts import render
from django.http import HttpResponse
def myview(request):
return HttpResponse("Hello There =)")
def process_view_test(request):
return HttpResponse("Hello There =)")
@hamedsj
hamedsj / urls.py
Created May 3, 2020
myapp/urls.py
View urls.py
from django.urls import path
from . import views
urlpatterns = [
path('myview/', views.myview),
path('process_view_test/', views.process_view_test)
]
@hamedsj
hamedsj / urls.py
Created May 3, 2020
mysite/urls.py
View urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('myapp.urls'))
]
You can’t perform that action at this time.