Skip to content

Instantly share code, notes, and snippets.

@Meroje
Meroje / 0-README.md
Last active August 29, 2015 13:58
The Twitter emoji scanner

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.

@Meroje
Meroje / comment.php
Created December 4, 2013 07:43
TimeDiff For Humans
<?php
use Carbon\Carbon;
class Comment extends Eloquent {
protected $guarded = array();
protected $softDelete = true;
public static $rules = array();
<?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);
<?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))
@Meroje
Meroje / dabblet.css
Last active December 14, 2015 22:39
.elem outline box, from http://learnlayout.com/
/**
* .elem outline box
*/
.elem {
border: solid #6AC5AC 3px;
position: relative;
}
.elem p {
@Meroje
Meroje / global.php
Created December 14, 2012 11:45
Illuminate custom Router (from JasonLewis)
$app['router'] = $app->share(function($app)
{
return new Feather\Routing\Router($app);
});
@Meroje
Meroje / 1-Entity-Repository-Controller-Pattern.md
Created November 18, 2012 20:53
Entity Repository in Laravel4

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 / cacheabletrait.php
Created November 17, 2012 14:51
CacheableTrait (from ShawnMcCool)
<?php
trait CacheableTrait
{
protected $cache = array();
public function request_cache($key, \Closure $closure)
{
// return the cache if it exists
if(!isset($this->cache[$key]))
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>' : '';
});
/*
|--------------------------------------------------------------------------
| Register
|--------------------------------------------------------------------------
*/
Route::get('register', function()
{
return View::make('register');
});