Skip to content

Instantly share code, notes, and snippets.

View vikramj74's full-sized avatar
🎯
Focusing

Vikram Jaswal vikramj74

🎯
Focusing
View GitHub Profile
<?php
function addHTTP($url) {
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
$url = "http://" . $url;
}
return $url;
}
$testCases = [
[
#! /usr/local/bin/bash
# A simple utitlity to SSH easily into remote servers
# You can assign nick names to the IPs, and then use
# the nick to SSH into the particular server
declare -A ips=( \
[izPanel]=35.185.138.140 \
[izRepo]=35.196.99.250 \
);
<?php
class SequentialLogReader {
private $basePath;
private $logFileName;
private $dayWindow;
private $timeWindow;
private $logProcessor;
public function __construct($basePath, $logFileName, $timeWindow, $dateOffset = null,$dateFormat = null) {
#! /bin/bash
# An array containing all the paths that
# need to be added to the $PATH variable
PATHS2ADD=( \
"/home/vikram/scripts" \
)
# Loop over the array and
# and add all the paths to
<?php
namespace LoggerPlus;
class LoggerPlus
{
public static function writeDatewiseLog($logdir, $filename, $logstr)
{
$logstr .= "\n";
if (is_dir($logdir . date('Y'))) {
grep -Rc "$1" ./ | grep -v ":0" ;
package main
import (
"time"
)
func FormatToStandardTimeString(givenTime time.Time) (string) {
return givenTime.Format("2006-01-02 15:04:05")
}
package debuggin_helpers;
import (
"fmt"
)
func RepresentType(t interface{}) string {
return fmt.Sprintf("--> %#v", t)
}
<?php
class Utils {
public static function getJsonFromQueryResult($qr) {
$arr = array();
while($row = $result->fetch_assoc()) {
$arr[] = $row;
}
return json_encode($arr);
}
<?php
/**
* Returns a simple formatted string which maybe printed in a log file
* @param $params array
*/
function getFormattedLogString($params) {
$timeStamp = date('Y-m-d H:i:s');
return "\n".$timeStamp.'!~!'.json_encode($params);
}