This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var filendir = require('filendir'); | |
function define(fileName, args, func) { | |
var content = ''; | |
if (typeof func === 'function') { | |
content = "define('" + fileName + "', \n" + JSON.stringify(args).replace(/,/g, ",\n") + ", \n" + func.toString() + "\n);"; | |
} else if (typeof args === 'function') { | |
content = "define('" + fileName + "',\n" + args.toString() + "\n);"; | |
} | |
filendir.ws(fileName + ".js", content); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function curl($Url,$args = array()) { | |
//Translate get params. | |
if(count($args)>0) { | |
$tab=array(); | |
while (list($key, $value) = each($args)) { | |
$tab[]=$key."=".$value; | |
} | |
$get="?".implode("&",$tab); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
potato |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClippings extends Shortcode { | |
public $name = "my-clippings"; | |
static $clippings; | |
static function load_clippings() { | |
if( ! self::$clippings ) { | |
self::$clippings = file_get_contents( "https://drive.google.com/uc?export=download&id=[SOME FILE ID FROM Gdrive]" ); | |
} | |
} | |
function process( $filter ) { | |
self::load_clippings(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/php | |
<?php | |
function get_funcs( $dir ) { | |
if ( is_dir( $dir ) ) { | |
$files = scandir( $dir ); | |
$funcs = array(); | |
foreach ( $files as $file ) { | |
if ( substr( $file, 0, 1 ) !== '.' ) { | |
$funcs = array_merge( $funcs, get_funcs( $dir . "/" . $file ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================ | |
Script filter: | |
var q = "{query}"; | |
var values = Application('Evernote').findNotes("notebook:Snippets " + q); | |
var ret = '<?xml version="1.0"?><items>'; | |
for (var i=0; i<values.length; i++ ) { | |
var title = values[i].title(); | |
var val = values[i].htmlContent().replace(/<br\/>/g,'{enter}').replace(/<[^>]*?>/g,""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This page should be visible only for 48 hours since the first visit | |
// Drop this in functions.php | |
function make_the_page_visible_only_certain_time_after_first_visit() { | |
$secret_page = PAGE_ID_HERE; | |
$redirect_to_when_expired = URL_TO_REDIRECT; | |
$time_to_visit = 48 * 3600; //48h | |
if ( is_page( $secret_page ) && ! is_user_logged_in() ) { | |
if ( empty( $_GET[ 'visitor_id' ] ) ) { | |
wp_redirect( URL_OF_EXPIRED_PAGE ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://piszek.com/2020/05/27/evernote-transcriber/ | |
function transcribe_audio_file_in_a_note( $evernoteClient, $note ) { | |
// This will find the place where file is embedded, so we can display the transcription underneath. | |
if( preg_match( '#<en-media hash="([a-z0-9]+)"[^>]+>#is', $note->content, $res ) ) { | |
$id = hex2bin($res[1] ); | |
$resources = array_filter( $note->resources, function( $resource ) use ( $id ) { | |
return $resource->data->bodyHash === $id; | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put that in functions.php in your theme | |
add_filter( 'the_content', $content, 'private_podcast', 10, 1 ); | |
function private_podcast( $content ) { | |
if( has_category( 'podcast' ) && ! has_access() ) { | |
return "This is a private podcast. Please subscribe here"; | |
} | |
return $content; | |
} | |
function has_access() { | |
global $_GET; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Drop this in functions.php or your plugin. | |
// You NEED to have Parsedown.php also : https://github.com/erusev/parsedown | |
wp_embed_register_handler( | |
'github_readme_md', | |
'&https?:\/\/github\.com\/([a-zA-Z-_0-9/]+)\/([a-zA-Z]+)\.md&i', | |
__NAMESPACE__ . '\artpi_github_markdown_handler' | |
); | |
function artpi_github_markdown_handler( $matches, $attr, $url, $rawattr ) { |
OlderNewer