Skip to content

Instantly share code, notes, and snippets.

View jleei's full-sized avatar

JLee jleei

  • Remote
View GitHub Profile
@jleei
jleei / fortify-confirm-2fa.patch
Created December 25, 2021 03:48 — forked from dmandrade/fortify-confirm-2fa.patch
Adds option to confirm activation of 2FA
Adds option to confirm activation of 2FA
@package laravel/fortify
--- /dev/null
+++ database/migrations/2021_06_01_145800_add_two_factor_confirmed_column_to_users_table.php
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
@jleei
jleei / ApiResponse.php
Created March 18, 2021 01:20 — forked from jtelesforoantonio/ApiResponse.php
Trait API Responses for Laravel
<?php
namespace App\Traits;
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
trait ApiResponse
{
/**
@jleei
jleei / binance_get_historical_klines.py
Created October 19, 2020 01:26 — forked from sammchardy/binance_get_historical_klines.py
Get historical Klines from Binance
# uses the date_to_milliseconds and interval_to_milliseconds functions
# https://gist.github.com/sammchardy/3547cfab1faf78e385b3fcb83ad86395
# https://gist.github.com/sammchardy/fcbb2b836d1f694f39bddd569d1c16fe
from binance.client import Client
import time
def get_historical_klines(symbol, interval, start_str, end_str=None):
"""Get Historical Klines from Binance
@jleei
jleei / square_thumb.py
Created December 22, 2019 07:50 — forked from kellan/square_thumb.py
square thumbnails with Python PIL (Pillow), make sure to rotate correctly
from __future__ import print_function
from PIL import Image, ExifTags
def square_thumb(img, thumb_size):
THUMB_SIZE = (thumb_size,thumb_size)
exif=dict((ExifTags.TAGS[k], v) for k, v in img._getexif().items() if k in ExifTags.TAGS)
if exif['Orientation'] == 3 :
img=img.rotate(180, expand=True)
@jleei
jleei / README.md
Created December 3, 2019 19:45 — forked from shadiakiki1986/README.md
Run a Scrapy spider in a Celery Task (in django)

My first shot at fixing this was in tasks.py file below.

But then that just gave a "unhandled error in deferred", so I went on to use CrawlRunner.

That showed no output at all anymore, and didn't run as expected.

Eventually, I just settled on CELERY_WORKER_MAX_TASKS_PER_CHILD=1=1 in settings.py

Note: CELERY_WORKER_MAX_TASKS_PER_CHILD=1 is for django. Celery without django probably drops the CELERY_ prefix

@jleei
jleei / docker-compose.yml
Created November 28, 2019 16:55 — forked from tingwei628/docker-compose.yml
use postgresql and pgAdmin in docker
version: "3.4"
services:
pgAdmin:
restart: always
image: dpage/pgadmin4
ports:
- "8000:80"
environment:
PGADMIN_DEFAULT_EMAIL: 1234@admin.com
@jleei
jleei / remove_duplicates.py
Created November 28, 2019 10:11 — 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)
)
@jleei
jleei / AppContext.js
Created October 7, 2019 12:51
React Snippets #react
import React, { useState } from 'react';
const initialState = {
app: {
hasLoaded: false
}
};
const AppContext = React.createContext(initialState);
@jleei
jleei / gulpfile.js
Created December 12, 2018 03:49 — forked from demisx/gulpfile.js
Gulp 4 gulpfile.js
// Gulp 4
var gulp = require('gulp');
var using = require('gulp-using');
var grep = require('gulp-grep');
var changed = require('gulp-changed');
var del = require('del');
var coffee = require('gulp-coffee');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var sourcemaps = require('gulp-sourcemaps');