Skip to content

Instantly share code, notes, and snippets.

@manofi21
manofi21 / 1. initilitation_declaration.dart
Last active July 31, 2021 14:56
realtime database syntax in flutter
// declaration and inisialitation variable
int _counter;
DatabaseReference _counterRef;
DatabaseReference _messagesRef;
StreamSubscription<Event> _counterSubscription;
StreamSubscription<Event> _messagesSubscription;
bool _anchorToBottom = false;
String _kTestKey = 'Hello';
String _kTestValue = 'world!';
@Composable
private fun RotatingText() {
RotateIndefinitely(durationPerRotation = 4000) {
Text("Rotating text!")
}
}
@slightfoot
slightfoot / column_builder.dart
Last active July 6, 2024 03:28
Column Builder for Flutter. Can be used instead of a ListView with shrinkWrap.
class ColumnBuilder extends StatelessWidget {
final IndexedWidgetBuilder itemBuilder;
final MainAxisAlignment mainAxisAlignment;
final MainAxisSize mainAxisSize;
final CrossAxisAlignment crossAxisAlignment;
final TextDirection textDirection;
final VerticalDirection verticalDirection;
final int itemCount;
@james2doyle
james2doyle / model-update-return.php
Created May 26, 2017 18:11
Update a Laravel Eloquent model and return the fresh model
<?php
// find the model, update the model, give me the fresh model
$updatedUser = tap(User::find(1), function ($user) use ($data) {
return $user->update($data);
})->fresh();
@naveenyagati
naveenyagati / Laravel PHP7 LEMP DigitalOcean.md
Last active September 1, 2020 03:59
Configuration for Installing Laravel with LEMP on Ubuntu 16.04 on Digital Ocean

Steps to install latest Laravel with LEMP on Digital Ocean Ubuntu 16.4

This tutorial is made based upon my experiences.In DigitalOcean Firewall in Configured by default so no changes are needed.Let's Encrypt has been pre-installed for us in Digita Ocean, please see: http://do.co/le-nginx

Install PHP 7 on Ubuntu

sudo apt-get update
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get install zip unzip
sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql php7.0-zip php7.0-gd
@technoknol
technoknol / custom validator in laravel to validate comma separated emails.php
Created May 5, 2017 08:28
custom validator in laravel to validate comma separated emails.
<?php
// custom validator in laravel to validate comma separated emails.
\Validator::extend("emails", function($attribute, $values, $parameters) {
$value = explode(',', $values);
$rules = [
'email' => 'required|email',
];
if ($value) {
foreach ($value as $email) {
$type = $request->input('email_or_phone');
$user = UserVerify::where('user_id', $request->input('user_id'))
->where(function($query) use ($type, $request) {
if ($type == 1) {
return $query->where('email', $request->input('email'));
}
if ($type == 2) {
return $query->where('mobile_no', $request->input('mobile_no'));
}
var required_fields = ['place','start_date','end_date','description'];
var message_errors = {
place : 'Place is required',
start_date : 'start_date required',
end_date : 'end_date is required',
description : 'description is required',
invalid_dates : 'Start date has to be less than end date'
};
@belohlavek
belohlavek / gh-pages-deploy.md
Last active August 21, 2022 19:33 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. Here's how to do it:

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore (or skip and force-add afterwards).

@UedaTakeyuki
UedaTakeyuki / install_laravel.sh
Created January 27, 2016 02:15
Install laravel 5.1 on Raspberry Pi.
# reference: http://stackoverflow.com/questions/31230133/how-to-make-a-raspberry-pi-2-laravel-5-1-server
apt-get install mysql-server mysql-client apache2 php5 php5-cli libapache2-mod-php5 php5-mysql php5-curl php5-gd php-pear php5-imagick php5-mcrypt php5-memcache php5-mhash php5-sqlite php5-xmlrpc php5-xsl php5-json php5-dev libpcre3-dev
sudo curl -sS https://getcomposer.org/installer | sudo php5
# create project
#composer.phar create-project laravel/laravel --prefer-dist projectName
#sudo chown -R www-data:www-data /var/www/
#sudo chmod -R 775 projectName