Skip to content

Instantly share code, notes, and snippets.

Avatar

Jérôme Foray Meroje

View GitHub Profile
View html.php
HTML::macro('flash', function()
{
$message_status = Session::get('message_status');
$message = Session::get('message');
return ($message && $message_status) ? '<div class="flash flash-' . $message_status . '">' . $message . '</div>' : '';
});
@Meroje
Meroje / cacheabletrait.php
Created Nov 17, 2012
CacheableTrait (from ShawnMcCool)
View cacheabletrait.php
<?php
trait CacheableTrait
{
protected $cache = array();
public function request_cache($key, \Closure $closure)
{
// return the cache if it exists
if(!isset($this->cache[$key]))
View 1-Entity-Repository-Controller-Pattern.md

Some Key points

[21:35:16] 1. Controllers call out to a repository to answer questions (like give me comments for a post, or are there any active users)
[21:35:27] so the repositories contain those business rules
[21:35:37] the entities (orm models) contain the application agnostic business rules
[21:35:42] like what makes a valid person
[21:36:09] 2. The repository interacts with the ORM to get the entities
[21:36:42] 3. The controller is merely responsible for processing the request, calling out to the appropriate repositories, and constructing the response
[21:36:52] All of the interactions are injected of course

@Meroje
Meroje / global.php
Created Dec 14, 2012
Illuminate custom Router (from JasonLewis)
View global.php
$app['router'] = $app->share(function($app)
{
return new Feather\Routing\Router($app);
});
View dabblet.css
/**
* .elem outline box
*/
.elem {
border: solid #6AC5AC 3px;
position: relative;
}
.elem p {
View 0-usage.php
<?php
with(new Page())->makeRoot();
with(new Page())->makePreviousSiblingOf(Page::find(1))
with(new Page())->makeNextSiblingOf(Page::find(1))
with(new Page())->makeLastChildOf(Page::find(5))
with(new Page())->makeFirstChildOf(Page::find(2))
Page::find(2)->children()
Page::find(2)->parent()
Page::find(2)->sibling()
Page::find(2)->isDescendant(Page::find(3))
View settings.php
<?php
class DBconfiguratorObject implements ArrayAccess, Serializable {
protected $config = array();
protected $table = null;
private static $_instance = null;
public static function instance($tableName = 'config'){
if(self::$_instance === null){
self::$_instance = new self($tableName);
@Meroje
Meroje / comment.php
Created Dec 4, 2013
TimeDiff For Humans
View comment.php
<?php
use Carbon\Carbon;
class Comment extends Eloquent {
protected $guarded = array();
protected $softDelete = true;
public static $rules = array();
@Meroje
Meroje / 0-README.md
Last active Aug 29, 2015
The Twitter emoji scanner
View 0-README.md

Purpose

This was used to find all possible urls of twitter's emojis.
The list is used for BetterTweetDeck's emojis replacement script.

Do it at home

First we export all characters from /System/Library/Input Methods/CharacterPalette.app/Contents/Resources/CharacterDB.sqlite3 (column uchr from table unihan_dict) as csv (could have used sqlite from nodejs). This file contains all unicode characters (54072).

Then this csv is parsed with nodejs, which outputs corresponding urls.

To find all emojis from there, you just have to test every urls (example, another, with paralelism) (be gentle, use HEAD) to remove those that return 404.

View keybase.md

Keybase proof

I hereby claim:

  • I am meroje on github.
  • I am meroje (https://keybase.io/meroje) on keybase.
  • I have a public key whose fingerprint is A279 58B4 FB91 2782 FC8D 5D3C 198D BC8B 3952 A88D

To claim this, I am signing this object:

You can’t perform that action at this time.