What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-22 20:25:36
component will mount hooks
// passing an empty array as second argument triggers the callback in useEffect // only after the initial render thus replicating `componentDidMount` lifecycle behaviour useEffect(() => { if(!props.fetched) { props.fetchRules(); } console.log(... Add solution -
Javascript 2022-01-22 03:31:43
reaction role by id discord.js
const Discord = require('discord.js'); const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] }); //partials arent really needed but I woudld reccomend using them because not every reaction is stored in the cache (it's new in v12... Add solution -
SQL 2021-11-22 08:52:21
convert sqlite table to pandas dataframe
import sqlite3 import pandas as pd dat = sqlite3.connect('data.db') query = dat.execute("SELECT * From <TABLENAME>") cols = [column[0] for column in query.description] results= pd.DataFrame.from_records(data = query.fetchall(), columns = ... Add solution -
Other 2021-11-19 05:39:26
didMount in functional component
// passing an empty array as second argument triggers the callback in useEffect // only after the initial render thus replicating `componentDidMount` lifecycle behaviour useEffect(() => { if(!props.fetched) { props.fetchRules(); } console.log(... Add solution -
Python 2021-11-19 00:05:10
read emails from gmail python
# Python 3.8.0 import smtplib import time import imaplib import email import traceback # ------------------------------------------------- # # Utility to read email from Gmail Using Python # # ------------------------------------------------ ORG_EMAIL = ... Add solution -
Other 2021-11-16 15:33:37
how-to-avoid-to-exceed-rate-limit-by-using-discord-js-api
client.fetchMessageRateLimits() .then(rateLimits => { for (rateLimit of rateLimits) { if (rateLimit.remaining === 0) { const msUntilReset = rateLimit.reset - Date.now(); commandHandler.ignoreChannel(rateLimit.channelId, msUn... Add solution -
Other 2021-11-15 19:02:11
duplicate key value violates unique constraint "django_migrations_pkey"
from django.db import connections query = "SELECT setval('django_migrations_id_seq', (SELECT MAX(id) FROM django_migrations))" cursor = connections['default'].cursor() cursor.execute(query) row = cursor.fetchone() Add solution