View social-helpers.php
<?php
function createFacebookShare($url, $title)
{
return '
<a href="http://www.facebook.com/share.php?u='. $url .'&title='. $title .'"><i class="fa fa-facebook-square"></i> SHARE</a>
';
}
function createTwitterShare($url, $title)
View line_break_canvas.html
<canvas id="myCanvas" width="720" height="379" style="border:1px solid"></canvas>
function wrapText(context, text, x, y, maxWidth, lineHeight) {
var words = text.split(' ');
var line = '';
for (var n = 0; n < words.length; n++) {
var testLine = line + words[n] + ' ';
var metrics = context.measureText(testLine);
var testWidth = metrics.width;
if (testWidth > maxWidth && n > 0) {
View routes.php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\JsonFormatter;
Route::get('/test', function() {
$user_info = [
'request_time' => date('Y-m-d H:m:i'),
'request_url' => $request->url(),
View Elegant.php
/**
* Create a new Elegant class
* And use that class from your model
*/
class Elegant extends Eloquent
{
protected $rules = array();
protected $errors;
View printSpecificElement.js
function printout() {
var newWindow = window.open();
newWindow.document.write(document.getElementById("out").innerHTML);
newWindow.print();
}
View helper
//Create New Folder Call MyClass on `app/` directory
Add new line on `/app/start/global.php`
ClassLoader::addDirectories(array(
app_path().'/commands',
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/MyClass', // This line is the one we need to add
View vim
//Deteact keyboard code when user type to the input
$('input').on('keydown', function (e) {
console.log(e.keyCode);
})
//For esc/i/j and k
$(document).keyup(function(e) {
if (e.keyCode == 27) { alert('esc') } // esc
if (e.keyCode == 73) { alert('i') } // i insert mode
if (e.keyCode == 74) { alert('j') } // j left
View variable_in_blade.php
{{ ''; $your_variable_name = 'Your Variable Value'; }}
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View JS Date Notes
## [To get first and last day of the month in js](http://stackoverflow.com/questions/13571700/get-first-and-last-date-of-current-month-with-javascript-or-jquery)
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
## For Month Select
function dateDropdown(select) {