Skip to content

Instantly share code, notes, and snippets.

View ionurboz's full-sized avatar

Onur ionurboz

View GitHub Profile
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@ionurboz
ionurboz / cron-list.php
Created February 24, 2021 06:26 — forked from stephenh1988/cron-list.php
Plugin: List wp cron jobs in wp_footer
<?php
! defined( 'ABSPATH' ) AND exit;
/*
Plugin Name: WP Cron Jobs List
Plugin URI: https://github.com/franz-josef-kaiser
Description: List WordPress internal cron jobs (array data) after the footer. Based on Kaiser's original plug-in https://gist.github.com/987128
Author: Franz Josef Kaiser, Stephen Harris
Author URI: https://github.com/franz-josef-kaiser
Version: 0.3
License: MIT
@ionurboz
ionurboz / wp-get-taxonomy-hierarchy.php
Created February 23, 2021 12:05 — forked from daggerhart/wp-get-taxonomy-hierarchy.php
WordPress function to get a complete taxonomy hierarchy of terms in PHP
<?php
/**
* Recursively get taxonomy and its children
*
* @param string $taxonomy
* @param int $parent - parent term id
* @return array
*/
function get_taxonomy_hierarchy( $taxonomy, $parent = 0 ) {
@ionurboz
ionurboz / XORCipher.js
Created December 4, 2020 06:47 — forked from sukima/XORCipher.js
A Super simple encryption cipher using XOR and Base64 in JavaScript
// XORCipher - Super simple encryption using XOR and Base64
//
// Depends on [Underscore](http://underscorejs.org/).
//
// As a warning, this is **not** a secure encryption algorythm. It uses a very
// simplistic keystore and will be easy to crack.
//
// The Base64 algorythm is a modification of the one used in phpjs.org
// * http://phpjs.org/functions/base64_encode/
// * http://phpjs.org/functions/base64_decode/
@ionurboz
ionurboz / map.js
Created November 20, 2020 09:50 — forked from AugustMiller/map.js
Map a number in one range to a number in another.
const mapNumber = (number, in_min, in_max, out_min, out_max) => {
return (number - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
};
@ionurboz
ionurboz / 2019-all-turkey-banks-binlist.csv
Created November 3, 2020 08:58
Güncel BKM Tüm Bankalar Bin Listesi - Ekim 2019
MemberNo MemberName PrefixNo CardType BusinessCard
10 T.C.ZİRAAT BANKASI A.Ş. 404591 CREDIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 407814 DEBIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 413226 CREDIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 444676 CREDIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 444677 CREDIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 444678 CREDIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 447504 DEBIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 454671 CREDIT CARD false
10 T.C.ZİRAAT BANKASI A.Ş. 454672 CREDIT CARD false
@ionurboz
ionurboz / wp-image-crop-position.php
Created October 28, 2020 07:49 — forked from bradt/wp-image-crop-position.php
WordPress: Set an image's crop position and rotates images based on EXIF information if necessary
<?php
/* Example Usage:
* bt_add_image_size( 'product-screenshot', 300, 300, array( 'left', 'top' ) );
* bt_add_image_size( 'product-feature', 460, 345, array( 'center', 'top' ) );
*/
add_filter( 'intermediate_image_sizes_advanced', 'bt_intermediate_image_sizes_advanced' );
add_filter( 'wp_generate_attachment_metadata', 'bt_generate_attachment_metadata', 10, 2 );
/**
@ionurboz
ionurboz / auto-login.php
Created October 28, 2020 07:38 — forked from bradt/auto-login.php
Automatic Logins for WordPress
<?php
class DBrains_Auto_Login {
protected static $_instance = null;
function __construct() {
global $wpdb;
$this->expires = DAY_IN_SECONDS * 30 * 4;
$this->table = $wpdb->prefix . 'dbrns_auto_login_keys';
@ionurboz
ionurboz / calculate_reading_time.php
Created October 19, 2020 07:37 — forked from tomhazledine/calculate_reading_time.php
Calculate Reading Time (for WordPress content)
<?php
/**
* READING TIME
*
* Calculate an approximate reading-time for a post.
*
* @param string $content The content to be measured.
* @return integer Reading-time in seconds.
*/
function reading_time( $content ) {

It's possible to some extent but won't be really accurate, the idea is load image with a known file size then in its onload event measure how much time passed until that event was triggered, and divide this time in the image file size.

Example can be found here: https://stackoverflow.com/questions/4583395/calculate-speed-using-javascript

Test case applying the fix suggested there: