Skip to content

Instantly share code, notes, and snippets.

View imajkumar's full-sized avatar

Ajay Kumar imajkumar

  • Developer
  • INDIA
View GitHub Profile
@imajkumar
imajkumar / index.php
Created October 3, 2019 13:33 — forked from ziadoz/index.php
Simple PHP / jQuery CSRF Protection
<?php
// See: http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html
// Start a session (which should use cookies over HTTP only).
session_start();
// Create a new CSRF token.
if (! isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32));
}
@imajkumar
imajkumar / traversing-example.md
Created April 3, 2019 12:17 — forked from etrepat/traversing-example.md
Traversing the Hierarchy Tree with Baum - An Example

The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.

<?php

$root = Category::roots()->with('children')->first();

echo "<h3>{$root->name}</h3>";

foreach($root->children as $category) {
@imajkumar
imajkumar / nginx.conf
Created March 26, 2019 11:41 — forked from ashleydw/nginx.conf
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;