Skip to content

Instantly share code, notes, and snippets.

View angelmartz's full-sized avatar

Juan Angel Martínez Lopez angelmartz

  • CDMX, Mexico
  • 12:12 (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);
<?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',
);
SELECT id, nombre, (6371 * ACOS(
SIN(RADIANS(lat)) * SIN(RADIANS(4.6665578))
+ COS(RADIANS(lng - -74.0524521)) * COS(RADIANS(lat))
* COS(RADIANS(4.6665578))
)
) AS distance
FROM direcciones
HAVING distance < 1 /* 1 KM a la redonda */
ORDER BY distance ASC