Skip to content

Instantly share code, notes, and snippets.

View petrk94's full-sized avatar

Petr K. petrk94

View GitHub Profile
@gullyn
gullyn / flappy.html
Last active November 28, 2023 18:23
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>
@jdormit
jdormit / wordpress-activitypub.org
Last active March 12, 2022 04:23
Notes about an ActivityPub implementation for Wordpress

Technical details

The plugin will do two things: set up an ActivityPub server running on the Wordpress instance, and transform the Wordpress web interface (both admin and public, e.g. comments) into an ActivityPub client.

Objects and collections

I want to offload as much of the object storage as possible to existing Wordpress capabilities. This means that instead of storing separate objects for blog posts, comments, users, etc., the server translates the data already in the WP database to the correct JSON representation on-demand when it needs to interact with these objects. However, there may be some additional metadata that the server needs to associate with the existing representations, which can be done using linking tables (post_id -> recipients, etc.).

Collections (inboxes, outboxes, likes, follows, etc.) will probably need to have their own tables in the DB, since there’s not an obvious analog to these in classic WP.

I want the object created by the plugin to be compatible with Mastodon, whic

@rahuldadhich
rahuldadhich / clear-string.php
Created January 10, 2018 11:44
PHP - Remove all special characters including white space, multiple space
function clean($string) {
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
}
@oliveratgithub
oliveratgithub / made-with-love.html
Last active April 19, 2024 17:06
Various snippets to add "Made with love" to your website using HTML, CSS and JavaScript
<!-- Example #1 - no styling -->
Made with ❤ in Switzerland
Made with ♥ in Switzerland
Made with ♡ in Switzerland
Made with ❤️ in Switzerland
Made with ♥️ in Switzerland
<!-- Example #2 - inline-styled ❤ -->
Made with <span style="color: #e25555;">&#9829;</span> in Switzerland
Made with <span style="color: #e25555;">&hearts;</span> in Switzerland
@fgilio
fgilio / remove-onclick.js
Created September 29, 2016 16:01
Remove onclick attribute from DOM element
document.getElementById('remove-onclick').removeAttribute("onclick");
@perguth
perguth / .htaccess
Last active January 28, 2024 19:01
Apache reverse proxy `.htaccess` file eg. for NodeJS. @Uberspace
SetEnvIf Request_URI "^(.*)" PORT=65300
RewriteEngine On
RewriteBase /
# CORS
Header add Access-Control-Allow-Origin "*"
# HTTPS
RewriteCond %{HTTPS} !=on
@Webklex
Webklex / mehrwertsteuer_berechnen.php
Created March 17, 2014 15:40
Mehrwertsteuer mit PHP berechnen
<?php
$netto = 1.50;
$mwsatz = 1.19; //19%
$brutto = $netto * $mwsatz;
$mwst = $brutto - $netto;
echo 'OUTPUT:'."\n";
@lerua83
lerua83 / extractNumbersString.php
Created November 13, 2013 13:20
PHP - Extract numbers from a string: URL: http://stackoverflow.com/questions/6278296/extract-numbers-from-a-string I want to extract the numbers from a string that contains numbers and letters like
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r($matches);
@BilalBudhani
BilalBudhani / rssToJson
Created January 31, 2013 10:04
PHP function to convert simple RSS to JSON
public function Parse ($url) {
$fileContents= file_get_contents($url);
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
$fileContents = trim(str_replace('"', "'", $fileContents));
$simpleXml = simplexml_load_string($fileContents);
$json = json_encode($simpleXml);
return $json;
}