Skip to content

Instantly share code, notes, and snippets.

View csarigoz's full-sized avatar

Cagri Sarigoz csarigoz

View GitHub Profile
@csarigoz
csarigoz / mobile-desktop_speed-optimization.gs
Last active October 7, 2019 21:10
Googlesheet Script that returns Mobile Speed & Optimization and Desktop Speed & Optimization values in six adjacent columns
/**
* Returns Mobile Speed & Optimization and Desktop Speed & Optimization values in six adjacent columns
* by Cagri Sarigoz
*/
function checkAll(Url) {
//CHANGE YOUR API KEY WITH YOUR_API_KEY BELOW
var key = "YOUR_API_KEY";
var serviceUrlMobile = "https://www.googleapis.com/pagespeedonline/v4/runPagespeed?url=" + Url + "&strategy=mobile&key=" + key;
var serviceUrlDesktop = "https://www.googleapis.com/pagespeedonline/v4/runPagespeed?url=" + Url + "&strategy=desktop&key=" + key;
@csarigoz
csarigoz / recursive_multiplication.py
Last active August 29, 2015 14:24
A Basic Recursive Integer Multiplication Algorithm
from random import randint
def recursive_mult(x, y):
if (x<10) or (y<10):
return x*y
x_str = str(x)
x_n = len(x_str)
y_str = str(y)
y_n = len(y_str)
@csarigoz
csarigoz / karatsuba.py
Created July 15, 2015 03:49
Karatsuba Algortihm for Integer Multiplication
from random import randint
def karatsuba(x, y):
if (x<10) or (y<10):
return x*y
x_str = str(x)
x_n = len(x_str)
y_str = str(y)
y_n = len(y_str)
@csarigoz
csarigoz / Hello Analytics.py
Created August 20, 2015 05:20
Hello Analytics for python 3 (with converting p12 secrets file to pem)
"""A simple example of how to access the Google Analytics API."""
import argparse
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
import httplib2
from oauth2client import client
from oauth2client import file
@csarigoz
csarigoz / run_exe_file_in_wine
Created March 8, 2016 08:24
Applescript for Running an exe file in wine
#open gemius explorer
tell application "Terminal"
do script "/usr/local/bin/wine ~/.wine/drive_c/Program\\ Files/Gemius/gemiusExplorer/gemiusExplorer.exe"
end tell
var key = "YOUR_API_KEY";
@csarigoz
csarigoz / filter_list_dict_key.py
Created July 4, 2022 16:06
Filter a List of Dictionaries By Key
users = [{'username': 'alice', 'age': 23, 'play_time': 101},
{'username': 'bob', 'age': 31, 'play_time': 88},
{'username': 'ann', 'age': 25},]
superplayers = [user for user in users if 'play_time' in user]
print(superplayers)
# resource: https://blog.finxter.com/how-to-filter-a-list-of-dictionaries-in-python/
@csarigoz
csarigoz / gist:cde2a4e2d8e684d042ffd5666aee0b8f
Created April 3, 2023 13:29
Google sheet custom formula to filter a column on pivot table by REGEXMATCH
=REGEXMATCH(TOP_PEOPLE,"cagri|cargri|cargi")
@csarigoz
csarigoz / google-sheet-link_url.gs
Last active April 5, 2023 13:31
Google sheet custom function that returns the URL of a hyperlinked cell, if it's entered with hyperlink command.
@csarigoz
csarigoz / thumbnail-in-rss-feed.php
Last active November 20, 2023 07:54
Add thumbnail image of posts to WordPress RSS Feed -> Add to functions.php file of your theme
// Add namespace for media:image element used below
add_filter( 'rss2_ns', function(){
echo 'xmlns:media="http://search.yahoo.com/mrss/"';
});
// insert the image object into the RSS item
add_action('rss2_item', function(){
global $post;
if (has_post_thumbnail($post->ID)){
$thumbnail_ID = get_post_thumbnail_id($post->ID);