Skip to content

Instantly share code, notes, and snippets.

@ravisorg
ravisorg / build-emoji-regexp.php
Last active November 6, 2023 08:18
Generate a PHP compatible regular expression to match emoji from the most recent unicode data.
<?php
/**
* Uses the data from unicode.org's emoji-data.txt to build a PHP compatible Regular Expression
* along the lines of:
* (?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\x{FE0F}?)
*
* To use: php build-hashtag-regexp.php <emoji-data.txt>
* Output will be the generated regular expression.
*
@ravisorg
ravisorg / test-hashtag-regexp.php
Last active December 13, 2018 05:50
pnut.io unicode hashtag parser
<?php
// You can find the test data file at https://www.ravis.org/hashtag-test.zip
// You're gonna want to have your console output supporting UTF8 before running this, or you're
// gonna see a bunch of ? in the output...
// For curiosity's sake, post number 693,847 is an emoji hashtag: #(heart)
@ravisorg
ravisorg / gist:9965595
Created April 4, 2014 00:25
Keybase proof
### Keybase proof
I hereby claim:
* I am ravisorg on github.
* I am ravisorg (https://keybase.io/ravisorg) on keybase.
* I have a public key whose fingerprint is 364E 3C99 43F4 8712 EA46 C5DF D3E1 06D5 5849 02CE
To claim this, I am signing this object:
@ravisorg
ravisorg / gist:3730015
Created September 15, 2012 22:01
Building HTML in JS
// create the main container for the post
var element = $('<div>',{
'class':'post encrypted',
'id':'post-'+postId,
'data-post-id':postId
});
// avatar
element.append($('<img src="'+post.user.avatar_image.url+'" class="avatar" />'));