Skip to content

Instantly share code, notes, and snippets.

View osbre's full-sized avatar
🇺🇦
#StandWithUkraine

Ostap Brehin osbre

🇺🇦
#StandWithUkraine
View GitHub Profile
@osbre
osbre / get-user-os.js
Created October 24, 2017 10:50
Function for get user operating-system name
function getOS() {
var userAgent = window.navigator.userAgent,
platform = window.navigator.platform,
macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
iosPlatforms = ['iPhone', 'iPad', 'iPod'],
os = null;
if (macosPlatforms.indexOf(platform) !== -1) {
os = 'Mac OS';
<?php
/**
* Replace day number to day name
* @number int
*/
function replaceNumberToString($number)
{
$dowMap = array(
'понеділок',
'вівторок',
//run command:
//php artisna tinker
//paste code and press enter
foreach(\DB::select('SHOW TABLES') as $table) {
$table_array = get_object_vars($table);
\Schema::drop($table_array[key($table_array)]);
}
@osbre
osbre / convert_meters_to_miles.php
Created August 26, 2018 14:59
PHP - convert miles to meters
<?php
$meters = 5302;
$miles = round($meters, 1, PHP_ROUND_HALF_UP);
echo $miles;
<?php
if ($request->hasFile('photos')) {
$allowedFileExtension = ['jpeg', 'jpg', 'png'];
$files = $request->file('photos');
foreach ($files as $file) {
$extension = $file->getClientOriginalExtension();
$check = in_array($extension, $allowedFileExtension);
if ($check) {
CREATE TABLE `products` (
`id` INT NOT NULL AUTO_INCREMENT,
`sku` varchar NOT NULL,
`title` varchar NOT NULL,
`description` TEXT NOT NULL,
`description_mini` TEXT NOT NULL,
`price` FLOAT NOT NULL,
`date` DATE NOT NULL,
`category_ids(JSON)` INT NOT NULL,
`payments_types(json)` INT NOT NULL,
<?php
/*
Api class for
https://ssl.easypay.by/merinfo/
*/
namespace App\Payments;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
rows = [
['x', 'x', 'x', 'x', 'x'],
['x', 'x'],
['x'],
]
for rowIndex, row in enumerate(rows):
nextRowIndex = rowIndex+1
if(nextRowIndex < len(rows)):
nextRow = rows[nextRowIndex]
@osbre
osbre / index.js
Last active June 23, 2019 22:09
DuckDuckGo search module (with puppeteer)
var search = require('./search.js');
search('github').then(function (links) {
console.log(links)
});
@osbre
osbre / helpers.php
Created July 15, 2019 12:17
[LARAVEL HELPERS] My collection of laravel helpers
<?php
/**
* Get old input value, and explode it by comma
* @param $key
* @return false|string
*/
function oldList($key)
{
return json_encode(