Skip to content

Instantly share code, notes, and snippets.

View voidnerd's full-sized avatar
:octocat:
Debugging

Ndifreke Friday voidnerd

:octocat:
Debugging
View GitHub Profile
@voidnerd
voidnerd / palindrome.php
Last active July 8, 2017 13:30
A php function that checks if string is Palindrome using OOP (Palindrome is a string that reads the same left-to-right and right-left-to-left).
<?php
class Palindrome {
public $words;
public $regex = '/[^A-Za-z0–9]/';
public $reserved;
public function __construct( $words)
{
<?php
class Router{
public $get = []; //when get routes are defined it is save here
public $post = []; // post routes are saved when when defined
//make a function that defined get routes
public function get($url, $controller) {
$this->get[$url] = $controller; // push url and controller to get property array
}
// JOGGLING ASYNC
var http = require('http');
var urls = [process.argv[2], process.argv[3], process.argv[4]];
var count = 0;
var arr = [];
function get(a) {
http.get(urls[a], (res) => {
var net = require('net');
var date = new Date();
var y = date.getFullYear();
var m = zeroCheck(date.getMonth() + 1);
var d = zeroCheck(date.getDate());
var h = zeroCheck(date.getHours());
var min = zeroCheck(date.getMinutes());
var http = require('http');
var fs = require('fs');
var server = http.createServer(function (req, res) {
res.writeHead(200, { 'content-type': 'text/plain' })
fs.createReadStream(process.argv[3]).pipe(res);
})
server.listen(process.argv[2]);
var http = require('http');
var server = http.createServer(function (req, res) {
var body = "";
res.writeHead(200, { 'content-type': 'text/plain' });
if(req.method != 'POST') {
return res.end('Please send a POST\n')
}
req.on('data', (data) => {
var http = require('http');
var url = require ('url');
var timestamp = (time) => {
return Date.parse(time)
}
var unixTimestamp = (time) => {
return {
unixtime: timestamp(time)
}
function encrypt(str, num) {
let len = str.substring(num, str.length - num).length;
let goin = '*'.repeat(len);
let res = str.slice(0, num) + goin + str.slice(str.length - num);
return res;
}
console.log(encrypt('111111111111111111111111111', 4)); // 1111*******************1111
<?php
function encrypt($str, $num){
$len = strlen(substr($str, $num, strlen($str) - $num));
$goin = str_repeat('*', $len);
$res = substr($str, 0 , $num) .$goin . substr($str, $len, strlen($str));
return $res;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div title="ok" id="oked"></div>