Skip to content

Instantly share code, notes, and snippets.

View angelmartz's full-sized avatar

Juan Angel Martínez Lopez angelmartz

  • CDMX, Mexico
  • 13:31 (UTC -06:00)
View GitHub Profile
@angelmartz
angelmartz / Game.php
Last active December 17, 2015 18:39 — forked from clouddueling/Game.php
<?php
class Game
{
public static function pointsFromLevel($level)
{
// http://rsdo.net/rsdonline/guides/Experience%20formula.html#PHP
$a=0;
for($x=1; $x < $level; $x++) {
$a += floor($x+300*pow(2, ($x/7)));
public static function search_contacts($terms)
{
$search_all = ! Input::has('first') && ! Input::has('last');
$terms = escape($terms);
$search_terms = explode(' ', $terms);
$search_term_bits = array();
foreach ($search_terms as $term) {
$term = trim($term);
if (! empty($term)) {
if ((Input::has('first') && Input::has('last')) || $search_all)
<?php
class Home_Controller extends Base_Controller
{
public function get_run()
{
phpconsole("WORKER: Initializing the CloudWorker.");
$love = true;
public static function search_contacts($terms)
{
$search_all = ! Input::has('first') && ! Input::has('last');
$terms = escape($terms);
$search_terms = explode(' ', $terms);
$search_term_bits = array();
foreach ($search_terms as $term) {
$term = trim($term);
if (! empty($term)) {
if ((Input::has('first') && Input::has('last')) || $search_all)
public static function search_contacts($terms)
{
$terms = escape($terms);
$contacts = Contact::where_account_user_id(Auth::user()->account_user_id)
->raw_where("match (`first`, `last`) against ('{$terms}*' IN BOOLEAN MODE)", array())
->where_account_user_id(Auth::user()->account_user_id)
->where_deleted(0)
->take(20)
->get();
public static function search_contacts($terms)
{
$terms = mysql_real_escape_string($terms);
$contact_results = Contact::where_account_user_id(Auth::user()->account_user_id)
->raw_where("match (`first`, `last`) against ('{$terms}*' IN BOOLEAN MODE)")
->where_deleted(0)
->paginate(20);
phpconsole($contact_results->results);
@angelmartz
angelmartz / Cache.php
Last active December 28, 2015 21:19
Eliminar cache, evitar botón atrás
public function removeCache()
{
$this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0',false);
$this->output->set_header('Pragma: no-cache');
}
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
<?php
// if you need the strtolower or some other data tweaks.
// remember me
$remember = Input::get('remember');
$credentials = array(
'username' => strtolower(Input::get('email')­),
'password' => Input::get('password'),
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);