Skip to content

Instantly share code, notes, and snippets.

View onurguven's full-sized avatar
🎯
Focusing

Onur onurguven

🎯
Focusing
View GitHub Profile
@rokibhasansagar
rokibhasansagar / tg_group_cleaner.py
Created March 4, 2020 20:37
Kick all the deleted accounts from a telegram chat using telethon.
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
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active June 23, 2024 21:19
Do not use forEach with async-await

Do not use forEach with async-await

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(...))

The problem

@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// 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

@OskarStark
OskarStark / InjectMediaUrlsListener.php
Last active February 15, 2021 05:08
If you need to get the SonataMedia public urls exposed through the api
<?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;
@dbranes
dbranes / functions.php
Last active November 3, 2017 12:56
Multiple comment forms and lists in single.php - wpquestions.com #9749
/**
* 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
*/
/**
@bcole808
bcole808 / get_cached_template_part.php
Created March 5, 2014 17:23
Wordpress template part caching system. Allows parts of a Wordpress template to be stored as site transients in order to speed up the rendering of your theme template parts.
<?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.
@Abban
Abban / facebook-url-parse.php
Created June 19, 2013 17:54
Code To parse FB url and Twitter username
<?
protected function valid_facebook_url($field){
if(!preg_match('/^(http\:\/\/|https\:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/', $field)){
return false;
}
return true;
}
@JimWestergren
JimWestergren / index-with-redis.php
Last active February 11, 2023 18:28
Redis as a Frontend Cache for WordPress
<?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/
@c3mdigital
c3mdigital / class-simple-local-avatars.php
Created June 24, 2012 04:53
Upload custom avatars for users to override gravatar for comments and author_meta
<?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
*/
@RalfAlbert
RalfAlbert / filters-for-simple-cache-template.php
Created June 7, 2012 23:53
Page template for WordPress with caching
<?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' );