Skip to content

Instantly share code, notes, and snippets.

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})

Laravel Snippets

Join a table to itself

e.g. a category that can have a parent_id which is another category

public function parent()
{
    return Category::where('id', '=', $this->category_id)->first();
<!DOCTYPE html>
<html class="no-js fuelux">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>E-Learning</title>
<link rel="stylesheet" href="https://fuelcdn.com/fuelux/2.3/css/fuelux.min.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
// Basic Random Image Rotator
// jQuery required http://jquery.com
// Easy option
// img is an array of images
var img = ['img1.jpg','img2.jpg','img3.jpg','img4.jpg'];
// src="images/rotator/ is path to your files contained in above array
$('<img src="images/rotator/' + images[Math.floor(Math.random() * images.length)] + '">').appendTo('#imageContainer');
////////////////////////////
<?php
$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$con = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
//select a database to work with
<?php
$username = "root";
$password = "";
$hostname = "localhost";
//Syndesi me vasi
$con = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
//Epilogi Database
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">