Skip to content

Instantly share code, notes, and snippets.

View leopard627's full-sized avatar
🎯
Focusing

Leopard627 leopard627

🎯
Focusing
View GitHub Profile
@leopard627
leopard627 / map3.py
Last active February 13, 2020 05:15
map3.py
def myfunc_v1(func, *args):
for arg in zip(*args):
yield func(*arg)
def myfunc_v2(func, *args):
return (func(*arg) for arg in zip(*args))
print(list(myfunc_v1(abs, [1, 2, -3])))
print(list(myfunc_v2(abs, [1, 2, -3])))
increaseCount = () => {
const { count } = this.state;
this.setState({
count: count + 1,
});
};
## models.py
class Tag(PrintableModel):
name = models.CharField(
verbose_name=_('Name'),
db_index=True,
max_length=150,
help_text="태그 이름",
unique=True)
import datetime
KST = datetime.timezone(datetime.timedelta(hours=9))
kst_now = datetime.datetime.now(KST)
class Movie(models.Model):
rate = models.FloatField()
q1 = Movie.objects.filter(rate=1.0).count()
q2 = Movie.objects.filter(rate=2.0).count()
q3 = Movie.objects.filter(rate=3.0).count()
q4 = Movie.objects.filter(rate=4.0).count()
q5 = Movie.objects.filter(rate=5.0).count()
class Movie(models.Model):
title = models.CharField()
rate = models.FloatField()
......
....
...
.......
@leopard627
leopard627 / read-access.sql
Created November 13, 2020 07:42 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
# asyncio/events.py in get_event_loop at line 602
not self._local._set_called and
isinstance(threading.current_thread(), threading._MainThread)):
self.set_event_loop(self.new_event_loop())
if self._local._loop is None:
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
return self._local._loop
def set_event_loop(self, loop):
@leopard627
leopard627 / dummy_views.py
Created November 15, 2020 12:12
asyicIO with django view
import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
def send_email_with_asyncio(user, email):
# email sending logic
# .........................
# .................................
@leopard627
leopard627 / dnsovertls.md
Created January 4, 2023 11:47 — forked from uraimo/dnsovertls.md
Configure your Mac to use DNS over TLS