Skip to content

Instantly share code, notes, and snippets.

@simonhamp
simonhamp / AppServiceProvider.php
Last active June 12, 2024 11:05
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@dolph
dolph / _README.md
Last active June 12, 2024 11:06
tl;dr zero-downtime database migrations in SQLite using triggers
  • Zero-downtime: Multiple releases of the code that understand different database schemas can simultaneously write to the database.

  • Triggers: Triggers are used to keep old and new schemas in sync while the application undergoes a rolling upgrade.

  • Expand-migrate-contract: The migration is performed in three phases. The expand phase creates new columns (and possibly tables), and triggers. The migrate phase moves data from the old column to the new column. The contract phase removes old columns (and possible tables), and triggers.

@lopspower
lopspower / README.md
Last active June 12, 2024 11:01
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@Kartones
Kartones / postgres-cheatsheet.md
Last active June 12, 2024 10:59
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
from transformers import ElectraForMaskedLM, ElectraForPreTraining
from transformers.models.electra.modeling_electra import ElectraForPreTrainingOutput
from torch import Tensor
import torch.nn.functional as F
import torch.nn as nn
import torch
class ElectraModel(nn.Module):
def __init__(self,
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active June 12, 2024 10:58
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
@nicostombros
nicostombros / data-table.tsx
Last active June 12, 2024 10:57
Shadcn UI implementation of DataTable and Pagination components working together
// same as your regular shadcn datatable implementation (which uses tanstack table)
// note that the shadcn datatable uses shadcn table for the ui. see https://ui.shadcn.com/docs/components/data-table
import {
ColumnFiltersState,
SortingState,
VisibilityState,
flexRender,
getCoreRowModel,
getFilteredRowModel,
@muhammadwaqarqsol
muhammadwaqarqsol / data-table.tsx
Created June 12, 2024 10:57 — forked from nicostombros/data-table.tsx
Shadcn UI implementation of DataTable and Pagination components working together
// same as your regular shadcn datatable implementation (which uses tanstack table)
// note that the shadcn datatable uses shadcn table for the ui. see https://ui.shadcn.com/docs/components/data-table
import {
ColumnFiltersState,
SortingState,
VisibilityState,
flexRender,
getCoreRowModel,
getFilteredRowModel,
@xbeta
xbeta / README.md
Last active June 12, 2024 10:56
Macbook Pro Bluetooth + WiFi 2.4GHz interference fix for Mavericks
@billhhh
billhhh / google-api-docs-offline.md
Created June 12, 2024 10:55 — forked from chrisroos/google-api-docs-offline.md
Using wget to create offline copies of Google API docs

I've used this in the past to grab offline copies of some of the Google API docs.

$ wget --no-parent --recursive --page-requisites --html-extension --convert-links "http://code.google.com/apis/gears/"

# --no-parent - Don't fetch anything in the parent directory of the URL specified
# --page-requisites - Download everything required for the page to display correctly
# --recursive - Recursively download (use default depth of 5)
# --html-extension - Add .html to downloaded html files (this isn't necessarily required for the google code example but might be useful on other sites)

--convert-links - Update links in the downloaded document to point to, either the downloaded copy of a file or a full URL