Skip to content

Instantly share code, notes, and snippets.

View eli-oat's full-sized avatar

Eli Mellen eli-oat

View GitHub Profile
@eli-oat
eli-oat / get-title.md
Created June 14, 2017 01:49
Get title attribute form a URL via PHP curl

Currently, whenever I reply to or like a link the source URL displays. I've found a really sturdy way to parse content titles, but the performance is absolutely abysmal. Wicked wicked wicked slow. I think it may be something to do with how I'm invoking the function. I'll keep poking at it, though, since it makes for a much better presentation.

function url_get_title($url)
    {
    if (!function_exists('curl_init'))
        {
        die('CURL is not installed!');
        }
    $ch = curl_init();
<?php
function url_get_title($url)
{
if (!function_exists('curl_init'))
{
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@eli-oat
eli-oat / downloader.sh
Created September 5, 2017 12:37
Download a website
#!/bin/bash
printf "\n\n Please enter the URL of the website you wish to download.\n Do not include leading 'http://' or 'https://'?\n\n\n"
printf " "
read URL
printf "\n\n Depending on the size of the website you just\n entered, this may take a few minutes.\n\n\n"
sleep 6
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains ${URL} --no-parent http://${URL}
printf "\n\n DONE!\n\n\n"
<style id="jsbin-css">
main > .tab:last-of-type {
order: 0;
}
main > article:last-of-type {
display: flex;
}
main > article:target ~ article {
display: none;
}
@eli-oat
eli-oat / .vimrc
Created October 24, 2017 02:03 — forked from jackbaty/.vimrc
.vimrc as of 2017-10-21
" My current .vimrc file
" Jack Baty
" jack@baty.net
" Environment
set nocompatible " We don't want vi compatibility.
filetype off " still needed?
set shell=/bin/bash\ -i
@eli-oat
eli-oat / emojis.json
Created December 18, 2017 14:26 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family_mothers_two_girls", "shortname": "", "unicode": "", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family_mothers_children", "shortname": "", "unicode": "", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family_mothers_two_boys", "shortname": "", "unicode": "", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family_two_girls", "shortname": "", "unicode": "", "html": "&#128104;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👦", "name": "family_children", "shortname": "", "unicode": "", "html": "&#128104;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👦‍👦", "name": "family_two_boys", "shortname": "", "unicode": "", "html": "&#128104;&zw
@eli-oat
eli-oat / media-endpoint.php
Created February 20, 2018 15:37 — forked from aaronpk/media-endpoint.php
an example of a Micropub Media Endpoint https://www.w3.org/TR/micropub/#media-endpoint
<?php
$token_endpoint = 'https://tokens.indieauth.com/token';
$base_url = 'https://media.aaronpk.com/';
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Authorization');
if(isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/plain') !== false) {
$format = 'text';
} else {
@eli-oat
eli-oat / index.html
Created March 25, 2018 19:37
Stopwatch [A wicked simple stopwatch] // source https://jsbin.com/yubaki
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[A wicked simple stopwatch]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Stopwatch</title>
</head>
<body>
<h1>Stopwatch</h1>
@eli-oat
eli-oat / truncate.php
Last active April 17, 2018 19:40
PHP function to truncate a string to a certain length, and replace overflow with an ellip, makes sure not to truncate mid-word.
<?php
function truncate($text, $length = 75, $append = '&hellip;') {
$length = (int) $length;
$text = trim( strip_tags( $text ) );
if ( strlen( $text ) > $length ) {
$text = substr( $text, 0, $length + 1 );
$words = preg_split( "/[\s]|&nbsp;/", $text, -1, PREG_SPLIT_NO_EMPTY );
@eli-oat
eli-oat / select.md
Created March 27, 2018 15:11
trigger URL change on select element's change
<select onchange="location = this.options[this.selectedIndex].value;">
  <option>Please select</option> <option value="http://www.apple.com/">Apple</option>
  <option value="http://www.bbc.com">BBC</option> 
  <option value="http://www.facebook.com">Facebook</option> 
</select>