Skip to content

Instantly share code, notes, and snippets.

@Tom-Millard
Tom-Millard / curl_get_image
Created October 16, 2014 14:18
Curl get image and data
<?php
class curl_get_image{
private $image_name = "";
private $data = "";
private $dir = "";
private $details = array();
@jonathantneal
jonathantneal / facebook.php
Last active December 8, 2020 12:07
Getting social media feeds as JSON in PHP
<?php
/* Getting a JSON Facebook Feed
==========================================================================
1. Sign in as a developer at https://developers.facebook.com/
2. Click "Create New App" at https://developers.facebook.com/apps
3. Under Apps Settings, find the App ID and App Secret
<?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) {
@LucaRosaldi
LucaRosaldi / get-browser-language-code.php
Last active February 24, 2022 10:13
PHP: Get Browser Language, optionally passing a list of available languages.
<?php
/**
* Get browser language, optionally passing a list of available languages.
*
* @param [array] $available_languages Available languages for the site
* @param [string] $default Default language for the site
* @return [string] Language code
*/
function get_browser_language_code( $available_languages = [], $default = 'en' ) : string
{
@rajapaju
rajapaju / facebook-login.sh
Created October 12, 2011 18:00 — forked from hubgit/facebook-login.sh
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
@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}`
@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
#
@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
@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++) {
@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')