Skip to content

Instantly share code, notes, and snippets.

View X-Raym's full-sized avatar

Raymond Radet X-Raym

View GitHub Profile
@brandonkramer
brandonkramer / notion.php
Last active October 17, 2023 21:18
(Notion.so) Notion API Integration (PHP) - A simple snippet which tells you, how to add a new page to a Notion database with PHP using Curl and their public API. You need a secret token and the ID of a "Shared" database. In the example below the database needs to have a text property called "Description" and the default "Name" property.
<?php
// Options
$secret_token = 'YOUR_SECRET_TOKEN';
$database_id = 'YOUR_DATABASE_ID';
$notion_version = '2021-08-16';
// Post url
$post_url = 'https://api.notion.com/v1/pages';
@cabrerahector
cabrerahector / wordpress-sort-posts-by-views.md
Last active April 15, 2023 17:57
[WordPress Popular Posts] Adding Views column to the Posts Manage page

Adding Views column to the Posts Manage page

This Gist shows how to add a sortable Views column to the post/page/custom-post-type edit screen.

Out of the box, the script will display the Views column on both the Posts and Pages screens. You can change that by editing the $post_types_with_views_column array at the beginning of the script.

How do I add this to my site?

  1. Using the text editor of your preference, create a file called wpp-sortable-columns.php and add the contents of this script to it.
  2. Place the wpp-sortable-columns.php file in wp-content\plugins.
#define REAPERAPI_NO_LICE
#define REAPERAPI_IMPLEMENT
#include "lice.h"
#include "reaper_plugin_functions.h"
#include <memory>
#include <map>
struct MyDLGTEMPLATE : DLGTEMPLATE
{
@danyell
danyell / htc.php
Last active May 12, 2022 22:17
.htaccess compiler
<?php
/*
* .htaccess compiler
*
* Recurse through all subdirectories, scan .htaccess files, and generate
* directives suitable for inclusion in an Apache configuration file.
* This lets you consolidate all .htaccess directives in the main
* (scanned once) Apache configuration. This has considerable
* performance and security benefits.
*
@hasibomi
hasibomi / changeurl.js
Last active July 20, 2023 22:47
Change URL in Browser Address Bar without reloading using JavaScript and jQuery
/* The solution found here: http://www.aspsnippets.com/Articles/Change-URL-in-Browser-Address-Bar-without-reloading-using-JavaScript-and-jQuery.aspx */
/** HTML5 History pushState method
* The pushState method works similar to window.location but it does not refresh or reload the page and it will modify the URL even if the page does not exists. The pushState method actually inserts an entry into the history of the browsers which allows us to go back and forth using the browser’s forward and back buttons.
* The pushState method accepts the following three parameters.
* 1. State object: - The state object is a JavaScript object which can contain any details about the page and must be serializable.
* 2. Title: - The title of the page.
* 3. URL – The URL of the page.
*/
function HexDump(buf)
local s = {}
s.output = ''
for byte=1, #buf, 16 do
local chunk = buf:sub(byte, byte+15)
s.output = s.output .. string.format('%08X ',byte-1)
chunk:gsub('.', function (c) s.output = s.output .. string.format('%02X ',string.byte(c)) end)
s.output = s.output .. string.rep(' ',3*(16-#chunk))
s.output = s.output .. chunk:gsub('%c','.') .. "\n"
end
@josephernest
josephernest / wavfile.py
Last active March 17, 2024 02:54
wavfile.py (enhanced)
# wavfile.py (Enhanced)
# Date: 20190213_2328 Joseph Ernest
#
# URL: https://gist.github.com/josephernest/3f22c5ed5dabf1815f16efa8fa53d476
# Source: scipy/io/wavfile.py
#
# Added:
# * read: also returns bitrate, cue markers + cue marker labels (sorted), loops, pitch
# See https://web.archive.org/web/20141226210234/http://www.sonicspot.com/guide/wavefiles.html#labl
# * read: 24 bit & 32 bit IEEE files support (inspired from wavio_weckesser.py from Warren Weckesser)
@Tagirijus
Tagirijus / fountain.py
Last active November 12, 2019 14:36
Python3 Fountain parser by Colton J. Provias (fixed by me)
"""
fountain.py
Ported to Python 3 by Colton J. Provias - cj@coltonprovias.com
Based on Fountain by Nima Yousefi & John August
Original code for Objective-C at https://github.com/nyousefi/Fountain
Further Edited by Manuel Senfft
"""
COMMON_TRANSITIONS = {'FADE OUT.', 'CUT TO BLACK.', 'FADE TO BLACK.'}
@maxkostinevich
maxkostinevich / functions.php
Last active February 11, 2023 20:03
WordPress: Export custom data to CSV
<?php
/**
* Export Data to CSV file
* Could be used in WordPress plugin or theme
*/
// A sample link to Download CSV, could be placed somewhere in plugin settings page
?>
<a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a>
@mintplugins
mintplugins / Make [edd_restrict] check for valid license.
Last active January 6, 2017 12:46
Make the [edd_restrict] shortcode check if the license is not expired in EDD Software Licensing
<?php
/**
* Check if the current user has a valid license for the $download_id passed-in.
*
* @param array ( 'download' => Download/Item ID (post_id), 'price_id' => Price ID )
* @return bool true/false
*/
function edd_sl_current_user_has_valid_license_for( $download_ids ){
// Get the current user ID