Skip to content

Instantly share code, notes, and snippets.

View quevon24's full-sized avatar
🏠
Working from home

Kevin Ramirez quevon24

🏠
Working from home
View GitHub Profile
@rain-1
rain-1 / LLM.md
Last active November 2, 2024 12:14
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

Smith,
Johnson,
Williams,
Brown,
Jones,
Garcia,
Miller,
Davis,
Rodriguez,
Martinez,
@leisurelicht
leisurelicht / admin.py
Last active August 20, 2024 00:44
Make all fields readonly for Django Admin
class OpsIPInfoAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
# make all fields readonly
readonly_fields = list(
set([field.name for field in self.opts.local_fields] +
[field.name for field in self.opts.local_many_to_many])))
if 'is_submitted' in readonly_fields:
readonly_fields.remove('is_submitted')
@Sanjay-Prajapati
Sanjay-Prajapati / LogoutInterceptor.kt
Last active January 8, 2019 10:27
Retrofit2 custom interceptor that parse the response from API. After that we can check status and based on that returns a same copy that other classes can consume.
import com.google.gson.Gson
import okhttp3.Interceptor
import okhttp3.Response
import okhttp3.ResponseBody
import org.json.JSONException
/**
* Logout Interceptor.
* Here i extend the BaseActivity to navigate user to another screen. i need runOnUIThread to execute navigateToLogin() method.
@neonankiti
neonankiti / MainActivity.java
Last active February 22, 2018 20:04
add onScrollStateChanged() for checking if there is an item view inside the screen. If so, tell the item view(VideoView) that it can start movie.
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
int firstCompletelyVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager())
.findFirstCompletelyVisibleItemPosition();
boolean isVideo = recyclerView.getAdapter()
.getItemViewType(firstCompletelyVisibleItemPosition) == TYPE_MOVIE;
@voghDev
voghDev / AddHeaderInterceptor.java
Last active August 22, 2018 08:44
Retrofit2 interceptor to add headers to HTTP requests
public class AddHeaderInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
builder.addHeader("Authorization", "headerContent");
return chain.proceed(builder.build());
}
}
@webserveis
webserveis / Obtener el path absoluto.md
Created July 2, 2016 08:19
Obtener el path absoluto de un uri

get uri from filechooser picker content://com.android.providers.downloads.documents/document/2303

con getRealPath(context,uri) se obtiene la ruta absoluta

file:///storage/emulated/0/Download/google-play-badge.png

@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active November 11, 2024 17:49
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@renyi
renyi / django-wkhtmltopdf-static-url-hack.py
Created May 21, 2016 10:38
django-wkhtmltopdf STATIC_URL hack to make static files work on both local and remote hosting.
def render_to_response(self, context, **response_kwargs):
from django.conf import settings
STATIC_URL = settings.STATIC_URL
if 'http' not in STATIC_URL:
# wkhtmltopdf requires full uri to load css
from urlparse import urlparse
parsed = urlparse(self.request.META.get('HTTP_REFERER'))
parsed = '{uri.scheme}://{uri.netloc}'.format(uri=parsed)
context["STATIC_URL"] = "{}{}".format(parsed, settings.STATIC_URL)
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));