TLDR: Use for...of
instead of forEach()
in asynchronous code.
For legacy browsers, use for...i
or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
from telethon import TelegramClient | |
from telethon.tl.functions.channels import EditBannedRequest | |
from telethon.tl.types import ChatBannedRights | |
import asyncio | |
import datetime | |
api_id = 1234 # Your API_ID | |
api_hash = "1a2b3c456" # Your APP_ID | |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
<?php | |
namespace Application\Sonata\MediaBundle\Listener; | |
use Application\Sonata\MediaBundle\Entity\Media; | |
use Doctrine\ORM\Event\LifecycleEventArgs; | |
use Sonata\MediaBundle\Provider\MediaProviderInterface; | |
use Sonata\MediaBundle\Provider\Pool; | |
use Symfony\Component\DependencyInjection\ContainerInterface; |
/** | |
* Example how to setup up multiple comment forms and comments lists | |
* | |
* @version 0.0.5 | |
* @file functions.php | |
* @see http://www.wpquestions.com/question/showLoggedIn/id/9749 | |
*/ | |
/** |
<?php | |
/** | |
* Retrieves a template part and caches the output to speed up site | |
* NOTE: Because we are caching display of posts, we need to make sure to delete the transients when posts are updated or published that might affect these template parts. | |
* | |
* Uses this function in conjunction with the WP cache: http://codex.wordpress.org/Function_Reference/get_template_part | |
* | |
* @param $slug (string) (required) The slug name for the generic template. | |
* @param $name (string) (optional) The name of the specialized template. | |
* @return (string) HTML output of the template part. |
<? | |
protected function valid_facebook_url($field){ | |
if(!preg_match('/^(http\:\/\/|https\:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/', $field)){ | |
return false; | |
} | |
return true; | |
} |
<?php | |
/* | |
Author: Jim Westergren & Jeedo Aquino | |
File: index-with-redis.php | |
Updated: 2012-10-25 | |
This is a redis caching system for wordpress. | |
see more here: www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/ |
<?php | |
/* | |
Plugin Name: Custom WordPress Avatars | |
Plugin URI: http://c3mdigital.com | |
Description: Adds a custom avatar uploader in the user profile to replace gravatars with a custom avatar | |
Version: 1.0 | |
Author: Chris Olbekson | |
Author URI: http://c3mdigital.com/ | |
License: GPL v2 | |
*/ |
<?php | |
add_action( 'save_post', 'clear_many_sites_transient', 10, 1 ); | |
add_action( 'edit_post', 'clear_many_sites_transient', 10, 1 ); | |
function clear_many_sites_transient( $post_id ){ | |
$post = get_post( $post_id ); | |
if( 'page' === $post->post_type ) | |
delete_transient( 'many_sites_in_one' ); |