This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function string_to_html(string $str) { | |
$str = str_ireplace("[newline]", "<br/>", $str); | |
$str = str_ireplace("[bold]", "<b>", $str); | |
$str = str_ireplace("[/bold]", "</b>", $str); | |
$str = str_ireplace("[italic]", "<i>", $str); | |
$str = str_ireplace("[/italic]", "</i>", $str); | |
$str = str_ireplace("[center]", "<span style=\"text-align:center;\">", $str); | |
$str = str_ireplace("[/center]", "</span>", $str); | |
$str = str_ireplace("[left]", "<span style=\"text-align:left;\">", $str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//'main' method must be in a class 'Rextester'. | |
//Compiler version 1.8.0_111 | |
import java.util.*; | |
import java.lang.*; | |
class Rextester | |
{ | |
public static boolean isNumeric(Object parameter) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Collections; | |
namespace Test | |
{ | |
public class Program | |
{ | |
public static int Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
def WordFrequency(filename, case_sensitive = True): | |
file = None | |
file_content = None | |
split_pattern = r"\t|\r|\n|\s+|\,|\.|\?|\!" | |
# Exceptions might occur, we don't want to print the native ugly error messages | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//nodejs v4.2.6 | |
'use strict'; // needed in nodejs v4.2.6 to enable "let" keyword | |
function GetURLParameters(url) { // url to provide as string | |
let parameters_string = url.split("?")[1]; // all parameters comes after "?" | |
let parameters = parameters_string.split("&"); // split to pairs of key/value | |
let parameters_object = {}; // the object which will contain those pairs | |
for (let i = 0; i < parameters.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertLinksToMultimedia(text) { | |
const regex = /(?<!src\=\')https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)\.(png|jpg|jpeg)(?!\')/i; | |
while (regex.test(text)) { | |
text = text.replace(regex, (match) => { | |
return "<img src='" + match + "'>"; | |
}); | |
} | |
return text; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists("StringToHTML")) { | |
function StringToHTML($string) { | |
// The following regular expression was originally formed by Diego Perini | |
// Take a look at it here: https://gist.github.com/dperini/729294 | |
$LinkRegex = "<\[url\](?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?\[\/url\]>u"; | |
$string = preg_replace_callback($LinkRegex, function($matches) { | |
$match = preg_replace("<\[url\]|\[\/url\]>", "", $matches[0]); | |
return "<a href='" . $match . "' target='_blank'>" . $match ."</a>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ColorAdapter.h" | |
RGB ColorAdapter::HexToRGB(int color) { | |
int Red = ((color & 0xFF0000) >> 16); | |
int Green = ((color & 0x00FF00) >> 8); | |
int Blue = color & 0x0000FF; | |
RGB Result; | |
Result.Red = Red; | |
Result.Green = Green; | |
Result.Blue = Blue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ColorAdapter.h" | |
RGB ColorAdapter::HexToRGB(int color) { | |
int Red = ((color & 0xFF0000) >> 16); | |
int Green = ((color & 0x00FF00) >> 8); | |
int Blue = color & 0x0000FF; | |
RGB Result; | |
Result.Red = Red; | |
Result.Green = Green; | |
Result.Blue = Blue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app; | |
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
public class App { | |
public static void main(String[] args) throws Exception { | |
int PORT_NUMBER = 45012; |
OlderNewer