Skip to content

Instantly share code, notes, and snippets.

Kana naneri

  • Bishkek
Block or report user

Report or block naneri

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@naneri
naneri / add_record_to_hosts.sh
Created Sep 2, 2018
Add a new line to hosts
View add_record_to_hosts.sh
echo 192.168.33.199 chef-automate.test | sudo tee -a /etc/hosts
@naneri
naneri / laravel.js
Created May 1, 2018
The delete button with my own csrf_token
View laravel.js
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{ csrf_token() }}" data-confirm="Are you sure?">
*/
(function() {
@naneri
naneri / cheats.sh
Last active Dec 21, 2018
My bash cheatsheet
View cheats.sh
# ==========
# Laravel
# ==========
# Laravel folder permissions
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
# ==========
# SSH
View deploy.sh
#!/bin/bash
currentFolder=${PWD##*/}
echo -e "$Cyan \n Updating System.. $Color_Off"
sudo apt-get update -y && sudo apt-get upgrade -y
echo -e "$Cyan \n Installing Apache2 $Color_Off"
sudo apt-get install apache2
@naneri
naneri / query.sql
Created May 20, 2017
$fLat is the searchers latitude and $fLon the searchers longitude.
View query.sql
SELECT
`id`,
`name`
FROM
`stations`
WHERE
ACOS( SIN( RADIANS( `latitude` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `latitude` ) )
* COS( RADIANS( $fLat )) * COS( RADIANS( `longitude` ) - RADIANS( $fLon )) ) * 6380 < 10
ORDER BY
`distance`
View select.blade.php
<select name="metrics_reminder" class="form-control list-group-item" required>
<option value="never" @if(old('course_reminder', $user->metrics_reminder) == 'never') selected @endif>Never</option>
@foreach(config('anya.metrics_reminder_intervals') as $value)
<option value="{{$value}}" @if(old('course_reminder', $user->metrics_reminder) == $value) selected @endif>
Once in {{$value}} days
</option>
@endforeach
</select>
@naneri
naneri / add_identity.sh
Last active Jul 29, 2016
Adds ssh identity to a server
View add_identity.sh
cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
@naneri
naneri / drop.php
Created Jul 17, 2016
Drop all tables in Laravel
View drop.php
<?php
foreach(\DB::select('SHOW TABLES') as $table) {
$table_array = get_object_vars($table);
\Schema::drop($table_array[key($table_array)]);
}
@naneri
naneri / tricks.md
Created Feb 23, 2016
Laravel tricks
View tricks.md

Adding seed data to migrations.

It often happens that you need some data to be available inside a migration. But the same data might be required in a Seeder (if you want to run it on test environtment). To make the data available for both in Seeder and Migration - you can simply call it inside a migration. Like that:

$seeder = new YourClassSeeder();
$seeder->run();

But you have to check inside the seeder file if the data is already available for your App, (so that you would not end up with two sets of the same data, after calling both migrations and seeders in testing machine).

@naneri
naneri / disable_global.sql
Last active Jan 27, 2016
Disable foreign key checks
View disable_global.sql
SET GLOBAL FOREIGN_KEY_CHECKS=0;
You can’t perform that action at this time.