Skip to content

Instantly share code, notes, and snippets.

View osw4l's full-sized avatar
🎹
Piano player

Oswaldo Rodriguez osw4l

🎹
Piano player
  • universidad libre de colombia
  • Barranquilla, Colombia
  • 14:40 (UTC -05:00)
View GitHub Profile
@osw4l
osw4l / curl.md
Created October 13, 2023 18:06 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

package connections
import (
"context"
"errors"
"reflect"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@osw4l
osw4l / kushki.html
Last active December 17, 2020 01:03
kushki subscription token from web
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kushki</title>
</head>
<body>
<script src="https://cdn.kushkipagos.com/kushki.min.js"></script>
<script>
const requestSubscriptionToken = () => {
@osw4l
osw4l / remove_duplicates.py
Created September 29, 2020 17:51 — forked from victorono/remove_duplicates.py
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
@osw4l
osw4l / auth.py
Created August 6, 2020 02:54
custom auth backend django
class CustomAuthenticationBackend:
def authenticate(self, request, email_or_phone=None, password=None):
try:
user = User.objects.get(
Q(email=email_or_phone) | Q(phone=email_or_phone)
)
pwd_valid = user.check_password(password)
if pwd_valid:
return user
class PaginatorMixin(object):
min_limit = 1
max_limit = 10
def paginate(self, object_list, page=1, limit=10, **kwargs):
try:
page = int(page)
if page < 1:
page = 1
except (TypeError, ValueError):
from django.db.models import Transform
class Trigram(Transform):
bilateral = True
lookup_name = 'trigram'
def as_postgresql(self, compiler, connection):
lhs, params = compiler.compile(self.lhs)
return "TRIAGRAM(%s)" % lhs, params
@action(detail=False, methods=['get'])
def action_view(self, request):
queryset = self.model.objects.all()
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
npm install nodemon
nodemon --exec "sls offline start" -e "extensions,to,watch,for,example,js,elm,hs,py"
@osw4l
osw4l / s3multipart.js
Created June 5, 2020 21:09 — forked from joshbedo/s3multipart.js
S3 multipart upload with NodeJS
var express = require('express')
var app = express()
var AWS = require('aws-sdk');
var bodyParser = require('body-parser');
var fs = require('fs');
var zlib = require('zlib'); // gzip compression
var multiparty = require('connect-multiparty'),
multipartyMiddleware = multiparty();