Skip to content

Instantly share code, notes, and snippets.

@sreejithpro
sreejithpro / delete_emails.gs
Last active March 15, 2023 16:00
Search for read email with sender and subject from a google doc and delete them
function deleteEmails() {
var sheet = SpreadsheetApp.openById('SHEET ID').getSheetByName('Sheet1');
var data = sheet.getDataRange().getValues();
for (var i = 1; i < data.length; i++) {
var sender = data[i][0];
var subject = data[i][1];
var threads = GmailApp.search('is:read from:' + sender + ' subject:' + subject);
Logger.log('Deleted' + i + ' emails')
@sreejithpro
sreejithpro / downloadUnreadEmails.gs
Last active March 15, 2023 15:49
Find unread emails in gmail and copy sender and subject in a google doc
function downloadUnreadEmails() {
var sheet = SpreadsheetApp.create('Unread Emails');
sheet.appendRow(['Sender', 'Subject']);
var threads = GmailApp.search('is:unread');
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
@SanariSan
SanariSan / readme.md
Last active April 13, 2024 07:15
Telegram HTTP bot API via CURL | Send text, photos, documents, etc.

Here are some examples on how to use Telegram bot api via CURL

Prerequisites

For getting messages in private chat with bot

  • Create a bot using @BotFather, get it's token
  • Start conversation with bot
  • Run following curl command
curl https://api.telegram.org/bot/getUpdates | grep -Po '"from":{"id":.+?,'
@iamrony777
iamrony777 / bot.rb
Created December 21, 2021 14:35 — forked from dideler/bot.rb
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
<?php
/**
* Check if the user has submitted the form.
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
/**
* Print the $_FILES global variable. This will display the following:
* array(1) {
* ["myfiles"]=> array(6) {
@isaumya
isaumya / wpcspc_device_based_cache_cf_worker_template.js
Last active February 18, 2023 22:50
Custom Cloudflare Worker Code for Device Based Caching - WP Cloudflare Super Page Cache Plugin
/**
* Worker Name: WPCSPC - Device based Cache
* Description: This worker is responsible for caching the requests based on the device type
* Based on Default Worker Version: 2.8.0
* Version: 2.1.0
* @link: https://wordpress.org/plugins/wp-cloudflare-page-cache/
* @link: https://wordpress.org/support/topic/mobile-page-theme-and-cloudflare-caching-plugin-integration/
* @author: Saumya Majumder
*/
// Default cookie prefixes for cache bypassing
@Greg-Boggs
Greg-Boggs / purge_cf.php
Last active August 7, 2023 09:23
PHP code to Purge Cloudflare Cache
<?php
// Replace EMAIL/API_KEY/ZONE_ID with your details.
// Zone ID is on the dashboard for the domain in the bottom right.
// Api keys are generated from the account settings. You must give cache purge permissions
// Place this script on your webserver and point a Github Webhook at it, and you'll clear
// the Cloudflare cache every time you do a push to GH.
$zoneId = "xxx";
$apiKey = "xxx";
$email = "xxx";
@janispritzkau
janispritzkau / analytics.js
Last active April 5, 2022 17:51
Minimal Google Analytics Script (677 bytes minified)
((document, location, navigator) => {
const domain = location.hostname.split(".")
const match = document.cookie.match(/(^|; ?)_ga=GA1\.\d\.(\d+\.\d+)(;|$)/)
// use existing client id or generate one
const cid = match ? match[2] : ~~(2147483648 * Math.random()) + "." + ~~(Date.now() / 1000)
// set cookie at highest possible domain level
for (let i = domain.length; i--;) {
const cookie = `_ga=GA1.${domain.length - i}.${cid}`
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@dideler
dideler / bot.rb
Last active April 17, 2024 08:40
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#