Skip to content

Instantly share code, notes, and snippets.

@aquasmit
aquasmit / keyBy-function-on-collection.md
Created December 19, 2016 03:41
Laravel - collection's keyBy function() to arrange records by one the keys

I found the solution with the function keyBy() on the collection (using laravel 5.1, 5.2)

 $collection = $collection->keyBy('id');

If you want to forget an item of your collection it unsets the right one then use following.

$collection->forget($item->id);
@aquasmit
aquasmit / laravel-call-controller-from-route-closure.md
Created December 17, 2016 12:43
Laravel - Call controller from route closure

Laravel - Call controller from route closure

Route::get('/example', function()
{
  // Run controller and method
  $app = app();
  $controller = $app->make('ExampleController');
  return $controller->callAction('index', $parameters = array());
@aquasmit
aquasmit / load-markers-on-google-map.md
Last active December 15, 2016 12:24
Load Markers on Google Map - workaround for loading large number of markers
@aquasmit
aquasmit / laravel-passing-variables-to-javascript.md
Created December 15, 2016 12:01
Laravel - Passing variables to JavaScript

Controller:

public function tableView()
{

        $sites = Site::all();
        return view('main.table', compact('sites'));
}
// Run from the dev tools console of any Youtube video
// Accurate as of October 28, 2016. Uses quality + video type for naming now,
// prevents video urls being overwritten.
// ES6 version
const videoUrls = ytplayer.config.args.url_encoded_fmt_stream_map
.split(',')
.map(item => item
.split('&')
.reduce((prev, curr) => (curr = curr.split('='),
@aquasmit
aquasmit / php-essential-extension.md
Created November 28, 2016 03:23
Essential PHP extensions
  1. php-cli
  2. php-common
  3. php-xml
  4. php-gd
  5. php-curl
  6. php-mcrypt
  7. php-mbstring
  8. php-xmlrpc
  9. libapache2-mod-php
@aquasmit
aquasmit / essential-ubuntu-commands.md
Created November 24, 2016 07:57
Essential Ubuntu Commands

How to move all files from current directory to upper directory?

mv * .[^.]* ..
@aquasmit
aquasmit / solve-ubuntu-permission-issue-for-apache.md
Last active November 28, 2016 05:06
Resolve permission issue on ubuntu

Summary of steps:

  1. Add current logged in user to www-data group
  2. Change ownership of /var/www directory to www-data group
  3. Change permissions of /var/www to 775 so that all members of www-data can have access to full access of /var/www. Note that this is not 755. If we set 755 then group members cannot have full access. That is why we are using 775.

Step 1: Assuming that 'ubuntu' is name of user with wich you are access ftp through filezilla then you can add that user to www-data group

@aquasmit
aquasmit / simple-curl.php
Created November 17, 2016 14:47 — forked from james2doyle/simple-curl.php
a simple PHP curl function to get the content type
function simple_curl($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$content = curl_exec ($ch);
@aquasmit
aquasmit / client.js
Created August 11, 2016 05:21 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});