Skip to content

Instantly share code, notes, and snippets.

@Sven65
Last active November 12, 2021 21:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sven65/c8531a3ed5bb8a3a8a6c260d3f8e2dc3 to your computer and use it in GitHub Desktop.
Save Sven65/c8531a3ed5bb8a3a8a6c260d3f8e2dc3 to your computer and use it in GitHub Desktop.
How to be a good programmer

How to be a good programmer

Step 1: Use a good programming language, like PHP, everyone loves PHP!

Step 2: Write a library that's useful! If you think it is, then it is, regardless of what others say, they only have more experience, what could they know?

Step 3: Use a good coding style, name your variables to something that is completely the opposite of what the variable actually is, this way you'll prevent evil hackers from stealing your code!!!

Step 4: Don't bother indenting, it's a waste of precious bytes on your harddrive and a wate of your precious time!

Step 5: Don't document your code or write anything about how you use it, it's a waste of time.

To make it easier for you to follow along, I've made this example;

<?php
class Format {
public function
__construct()
{
}
private function s_um_meg1c
($t_E_x_T)
{
$m_A_g_I_CL_3_t_t_3r_z_U_r_L = '%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu' ;
if(preg_match($m_A_g_I_CL_3_t_t_3r_z_U_r_L, $t_E_x_T, $u_R_l)) {
return preg_replace($m_A_g_I_CL_3_t_t_3r_z_U_r_L, "<a href='{$u_R_l[0]}''>{$u_R_l[0]}</a> ", $t_E_x_T) ;
}
else {
return $t_E_x_T ;
}
}
private function
b_O_l_D($t_E_x_T)
{
$m_A_g_I_CL_3_t_t_3r_z = "/\*([^\*]+)\*/" ;
return preg_replace($m_A_g_I_CL_3_t_t_3r_z, '&lt;b&gt;$1&lt;&sl;b&gt;', $t_E_x_T) ;}
private function
i_tA_L_iC($t_E_x_T) {
$m_A_g_I_CL_3_t_t_3r_z = "/\\/([^\\/]+)\\//" ;
return preg_replace($m_A_g_I_CL_3_t_t_3r_z, '&lt;i&gt;$1&lt;&sl;i&gt;', $t_E_x_T) ;
}
private function
sT_r_I_kE_($t_E_x_T) {
$m_A_g_I_CL_3_t_t_3r_z = "/~([^~]+)~/" ;
return preg_replace($m_A_g_I_CL_3_t_t_3r_z, '&lt;s&gt;$1&lt;&sl;s&gt;', $t_E_x_T) ;
}
private function
s_U_p($t_E_x_T) {
$m_A_g_I_CL_3_t_t_3r_z = "/\\^([^\\^]+)\\^/" ;
return preg_replace($m_A_g_I_CL_3_t_t_3r_z, '&lt;sup&gt;$1&lt;&sl;sup&gt;', $t_E_x_T) ;
}
private function
S_u_B($t_E_x_T) {
$m_A_g_I_CL_3_t_t_3r_z = "/:([^:]+):/" ;
return preg_replace($m_A_g_I_CL_3_t_t_3r_z, '&lt;sub&gt;$1&lt;&sl;sub&gt;', $t_E_x_T) ;
}
private function
u_N_De_r($t_E_x_T) {
$m_A_g_I_CL_3_t_t_3r_z = "/_([^_]+)_/" ;
return preg_replace($m_A_g_I_CL_3_t_t_3r_z, '&lt;ins&gt;$1&lt;&sl;ins&gt;', $t_E_x_T) ;
}
private function
m_A_gIX($t_E_x_T) {
return str_replace("&lt;", "<", str_replace("&gt;", ">", str_replace("&sl;", "/", $t_E_x_T))) ;
}
public function
format($t_E_x_T, $o_Pt_iOn_Z) {
if(in_array("link", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->s_um_meg1c($t_E_x_T) ;
}
if(in_array("bold", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->b_O_l_D($t_E_x_T) ;
}
if(in_array("italic", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->i_tA_L_iC($t_E_x_T) ;
}
if(in_array("strike", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->sT_r_I_kE_($t_E_x_T) ;
}
if(in_array("sup", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->s_U_p($t_E_x_T) ;
}
if(in_array("sub", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->S_u_B($t_E_x_T) ;
}
if(in_array("under", $o_Pt_iOn_Z)) {
$t_E_x_T = $this->u_N_De_r($t_E_x_T) ;
}
return $this->m_A_gIX($t_E_x_T) ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment