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 'dart:io'; | |
import 'package:device_info/device_info.dart'; | |
static Future<String> getDeviceId() async { | |
String result; | |
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); | |
if (Platform.isAndroid) { | |
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; | |
result = androidInfo.id; | |
} |
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
static Future<Uint8List> convertToUint8List({@required String url}) async { | |
Uint8List result; | |
try { | |
Response response = await client.get(url); | |
result = response.bodyBytes; | |
} on Exception catch (e) { | |
Helper.log(e); | |
} | |
return result; | |
} |
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
public function __invoke(User $user){ | |
$token = app('auth.password.broker')->createToken($user); | |
$user->sendPasswordResetNotification($token); | |
return { | |
'status' => 'success', | |
'message' => 'Email enviado com sucesso' | |
}; | |
} |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
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
public static string GenerateSlug(this string phrase) | |
{ | |
string str = phrase.RemoveAccent().ToLower(); | |
// invalid chars | |
str = Regex.Replace(str, @"[^a-z0-9\s-]", ""); | |
// convert multiple spaces into one space | |
str = Regex.Replace(str, @"\s+", " ").Trim(); | |
// cut and trim | |
str = str.Substring(0, str.Length <= 45 ? str.Length : 45).Trim(); | |
str = Regex.Replace(str, @"\s", "-"); // hyphens |
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
/** | |
* saveOriginalPhoto | |
* @param Request $request | |
* @param $sub_path | |
* @return string | |
*/ | |
public static function saveOriginalPhoto(Request $request, $sub_path) | |
{ | |
$File = $request->file('image'); | |
$real_name = md5(rand(11111, 99999)) . '_' . time() . '.jpg'; |
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
/** | |
* base64ToFile | |
* @param $base64 | |
* @param $path | |
* @param int $width | |
* @param int $height | |
* @return string | |
* @info usage 'Image' => Intervention\Image\Facades\Image::class | |
*/ | |
public static function base64ToFile($base64, $path, $width = 400, $height = 400) |
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
/** | |
* getIpInfo | |
* @param null $ip | |
* @return mixed | |
*/ | |
public static function getIpInfo($ip = null) | |
{ | |
if (!empty($ip) && !is_null($ip)) { | |
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json")); | |
return $details; |
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.Net; | |
using Newtonsoft.Json; | |
namespace Utils | |
{ | |
public class GoogleUtils | |
{ | |
private string _apiKey = ""; | |
private string _shortUrl = "https://www.googleapis.com/urlshortener/v1/url?fields=id%2ClongUrl%2Cstatus&key="; | |
private string _urlYoutubeLastVideos = "https://www.googleapis.com/youtube/v3/search?key="; |
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
/** | |
* Convert one simple date in Carbon instance object | |
* @param $date | |
* @param string $delimiter | |
* @return Carbon | |
*/ | |
public static function convertToCarbonInstance($date, $delimiter = '-') | |
{ | |
$sp_date = explode($delimiter, $date); | |
return Carbon::parse($sp_date[2] . '-' . $sp_date[1] . '-' . $sp_date[0]); |
NewerOlder