Skip to content

Instantly share code, notes, and snippets.

🛸

David Sword davidsword

🛸
View GitHub Profile
View emoji-to-hex-1.php
<?
$table = json_decode(file_get_contents('emoji.json'));
//print_r($table); //take a peak
foreach ($table as $k => $emoji)
foreach ($emoji->short_names as $shortname)
echo "'{$shortname}' => '{$emoji->unified}', \n";
?>
View emoji-to-hex-2.php
<?
$emoji_unicode = array(
'copyright' => '00A9',
'registered' => '00AE',
'bangbang' => '203C',
//...etc.
}
?>
View emoji-to-hex-3.php
<?
require('emoji_unicode.php');
$text = "hello :world_map: . it's :hammer: :stopwatch:.";
//alphanumeric, hyphens, plus-signs, and underscores string, wrapped in colons
preg_match_all("/:([a-zA-Z0-9'_+-]+):/", $text, $emojis);
foreach ($emojis[1] as $emojiname)
if (isset($emoji_unicode[$emojiname]))
View kindle-widget-1.css
#bookshelf {
width:156px;
margin: 0 auto;
}
.book {
-webkit-filter: grayscale(1);
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
background-size:cover;
View kindle-widget-2.php
<?
$curl_options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER =>; false,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_ENCODING => "",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 8,
CURLOPT_TIMEOUT => 8,
CURLOPT_MAXREDIRS => 3,
View kindle-widget-3.php
<?
// read cache and convert XML to ARRAY
$data_cache = explode($breaker,file_get_contents($cache));
$reading = new SimpleXMLElement($data_cache[0]);
$read = new SimpleXMLElement($data_cache[1]);
echo "<div id='bookshelf'>";
// cycle through currently reading (@TODO i dont know if cycle works nativily, only developed with 1 book in shelf. sometimes they change the xml structure when >1. would need to change)
foreach ($reading->reviews->review as $reading)
View object-buffering-not-working-flush-1.php
<?
ob_end_flush();
for( $i = 0 ; $i < 10 ; $i++ ) {
echo $i;
flush();
ob_flush();
sleep(1);
}
?>
View object-buffering-not-working-flush-2.php
<?
@ini_set('zlib.output_compression',0);
@ini_set('implicit_flush',1);
@ob_end_clean();
set_time_limit(0);
header( 'Content-type: text/html; charset=utf-8' );
ob_implicit_flush(1);
for($i=0; $i<10; $i++){
echo $i;
View wordpress-get-post-ids-navigation-menu-1.php
<?
$navigation_relation = array();
$navitems = wp_get_nav_menu_items('your-nav');
foreach ($navitems as $navobject)
$navigation_relation[$navobject->ID] = $navobject->object_id;
print_r($navigation_relation);
?>
You can’t perform that action at this time.