Skip to content

Instantly share code, notes, and snippets.

Avatar
Playing with code

Shameem Reza shameemreza

Playing with code
View GitHub Profile
View AnonymousFunctions.dart
var list = [1, 2, 3];
list.forEach((v) => print(v * 10));
View FunctionParameters.dart
import 'package:meta/meta.dart';
int sum(List<int> list, [int initial = 0]) {
var total = initial;
list.forEach((v) => total += v);
return total;
}
String joinToString(List<String> list,
{@required String separator, String prefix = ", String
suffix = "}) =>
'$prefix${list.join(separator)}$suffix';
View ConnecttoWebSocket.dart
WebSocket.connect('ws://demos.kaazing.com/echo').
then((WebSocket webSocket) {
webSocket.listen(print, onError: print);
webSocket.add('hello');
webSocket.add('world');
webSocket.close();
}).catchError(print);
View optional.php
// Example of using the optional() helper
print optional($dessert->name)->category;
View struuid.php
// We import the support for this helper
use Illuminate\Support\Str;
// We use the helper
echo($imagename) Str::uuid();
// We get a random identifier
6e358c39-9663-4a1f-b911-4fd6baaa5b1c
View arrhas.php
// We import the support for this Helper
use Illuminate\Support\Arr;
$products = ['drinks' => ['Name' => 'Strawberry Juice', 'price' => '3.60']];
$check = Arr::has($products, 'drinks.name');
// We get true
$check = Arr::has($products, ['drinks.name', 'drinks.price']);
View strslug2.php
$url = Str::slug('Shameem Reza', '+');
// We get the following friendly URL
shameem+reza
View strslug.php
$url = Str::slug('Shameem Reza');
// We get the following friendly URL
gelatina-de-fresa
View blank.php
// We analyze if there are blank or null values
blank('');
blank(' '); //Here we have blank spaces
blank(null);
// If there is a blank value or blank spaces we get 'true'
blank(0);
blank(true);
blank(false);
View arr::divide.php
// We import the support for this Helper
use Illuminate\Support\Arr;
// We use the method Arr::divide()
[$keys, $values] = Arr::divide(['name' => 'Shameem Reza', 'price' => '3.40']);
// We obtain the keys and values separately
$keys: ['name', 'price']
$values: ['Shameem Reza', '3.40']