Skip to content

Instantly share code, notes, and snippets.

View Mevrael's full-sized avatar

Mev-Rael Mevrael

View GitHub Profile
@Mevrael
Mevrael / WebSocketController.php
Created March 14, 2017 10:40
Laravel + WebSocket (Ratchet/ReactPHP) integration
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session;
use Ratchet\WebSocket\Version\RFC6455\Connection;
@Mevrael
Mevrael / mysql_5.7_join_json_column_id.sql
Last active January 11, 2024 16:58
MySQL 5.7 JOIN on JSON column of IDs
# Example for MySQL 5.7 how to use JOIN on 2 tables without junction table using new JSON column type.
# Let say we have 2 tables: posts and users
# Users may like posts
# We store the IDs of users who liked each post in posts.liked column which is a JSON array
# which might have a content like "[1, 2, 5, 10]"
SELECT posts.id AS post_id, users.id AS liked_by_user_id FROM posts JOIN users ON JSON_CONTAINS(posts.liked, CAST(users.id AS CHAR))
@YuriBrunetto
YuriBrunetto / es.js
Created September 20, 2016 17:31
ES6 shortcut - Get elements like jQuery
const $ = document.querySelector.bind(document)
// id
let divs = [
$("#div"),
$("#input")
]
// class
let other = [
@jmoz
jmoz / ratchet_redis.php
Created January 22, 2013 12:09
Ratchet and Predis-async. (React and Redis).
<?php
use RatchetApp\Pusher;
require __DIR__ . '/../vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$pusher = new Pusher();
$loop->addPeriodicTimer(10, array($pusher, 'timedCallback'));