Skip to content

Instantly share code, notes, and snippets.

View jgrossi's full-sized avatar
👨‍💻
probably writing code

Junior Grossi jgrossi

👨‍💻
probably writing code
View GitHub Profile
@jgrossi
jgrossi / functions.php
Last active August 29, 2015 14:27
PHP Namespace for functions
<?php
namespace { // default namespace
function foo()
{
return 'foo function';
}
}
@jgrossi
jgrossi / header.php
Created August 19, 2015 20:00
How to make a search with Wordpress
<?php // File wherer you include the form to make a search ?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
@jgrossi
jgrossi / gist:b477d97ab350f6b48e63
Created April 22, 2015 13:11
Customizing Corcel classes
<?php
// Creating your own class
namespace Your\Namespace;
use Corcel\Post as Corcel;
class Post extends Corcel
{
@jgrossi
jgrossi / rails.js
Created February 27, 2015 20:51
Rails jQuery adapter
(function($, undefined) {
/**
* Unobtrusive scripting adapter for jQuery
* https://github.com/rails/jquery-ujs
*
* Requires jQuery 1.8.0 or later.
*
* Released under the MIT license
*
@jgrossi
jgrossi / Math.php
Created November 11, 2014 22:18
Math class from Taylor Otwell. Thanks to @brad (captain_jim1@yahoo.com) for the class content.
<?php
class Math {
/**
* The base.
*
* @var string
*/
private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
<?php
class Entry extends Eloquent
{
protected function withPaymentsStatus($status)
{
return $this->whereHas('payments', function($query) {
$query->where('status', $status);
});
}
class Payment extends Eloquent
{
const PAID = 1;
const PENDIND = 2;
public function entry()
{
return $this->belongsTo('Entry', 'entry_id');
}