Skip to content

Instantly share code, notes, and snippets.

@robozavri
robozavri / 0_reuse_code.js
Created September 9, 2016 07:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
tinymce.init({
selector: 'textarea', // change this value according to your HTML
theme: "modern",
paste_data_images: true,
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime nonbreaking save table contextmenu directionality",
@robozavri
robozavri / sort array one by one
Created March 28, 2018 22:09
sort array one by one
<?php
// Sets up our arrays
$array1 = [1, 3, 5, 7, 9];
$array2 = [2, 4, 6, 8, 10];
$array3 = [];
// Determines how many items we have in each array
$array1_count = count($array1);
$array2_count = count($array2);
function arr_diff (a1, a2) {
var a = [], diff = [];
for (var i = 0; i < a1.length; i++) {
a[a1[i]] = true;
// a = [a: true, b: true, x: true]
// console.log(a1[i]);
}
//console.log(a);
@robozavri
robozavri / google map point get coordinate
Created May 9, 2018 10:02
get coordinate by point from google map
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<style media="screen">
#map_canvas {
width: 980px;
@robozavri
robozavri / laraadmin_laravel_redirect
Created May 14, 2018 13:21
laraadmin laravel admin redirect if is admin
namespace App\Http\Controllers\Auth;
class LoginController extends Controller
public function redirectTo(){
$roles = Auth::user()->roles;
if(!is_null($roles )){
foreach (Auth::user()->roles as $role) {
if($role->name == "SUPER_ADMIN"){
@robozavri
robozavri / google matric converter
Created June 20, 2018 07:58
google matric duration distance converter, converts distans value and duration value
/*
seconds:
12879
6262
metrs:
130229
*/
print 12879 / 60;
echo '<br>Hours : '. floor(12879 / 3600);
@robozavri
robozavri / php datatime diff
Created June 20, 2018 11:58
php datatime different
$start_date = new DateTime('2007-09-01 04:10:58');
$since_start = $start_date->diff(new DateTime('2012-09-11 10:25:00'));
echo $since_start->days.' days total<br>';
echo $since_start->y.' years<br>';
echo $since_start->m.' months<br>';
echo $since_start->d.' days<br>';
echo $since_start->h.' hours<br>';
echo $since_start->i.' minutes<br>';
echo $since_start->s.' seconds<br>';
@robozavri
robozavri / php add datetime to datetime
Created June 21, 2018 16:45
php add datetime to datetime
$datas = explode("/",'23/04/2018');
$correctDAta = $datas[2].'-'.$datas[1].'-'.$datas[0].' 10:00:00';
echo $correctDAta;
echo '<hr>';
$time = explode(":",'02:50:50');
//var_dump($time);
@robozavri
robozavri / php count sum times
Created June 22, 2018 13:19
php count sum times
echo sum_the_time('01:20:22', '02:10:00'); // this will give you a result: 19:12:25
function sum_the_time($time1, $time2) {
$times = array($time1, $time2);
$seconds = 0;
foreach ($times as $time)
{
list($hour,$minute,$second) = explode(':', $time);
$seconds += $hour*3600;
$seconds += $minute*60;