Skip to content

Instantly share code, notes, and snippets.

Ryan Rampersad ryanmr

Block or report user

Report or block ryanmr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View osn2019.md

Hey everyone,

I am living without a blog right now, but that has been on my mind over the last couple weeks. Setting up a blog tonight is definitely not workable, but setting up a simple blog-like gist is no problem at all.

I wanted to share here by Open Source North 2019 thoughts!

A brief preamble

In 2016, I learned of Open Source North and was lucky enough to receive a ticket from a friend. I attended that OSN as my first conference ever. Since then, I have promoted the idea of OSN being the best introduction conference for those new to the field. It's a local event, it's not too big, it's priced right (either inexpensive enough to be self-purchased as a student or pre-work, or cheap enough for a new hire to jump into without raising red flags at work for cost). I also say this is also a wonderfully well-rounded conference, ranging from frontend, to backend, to devops and more. Everything that intersects t

View keybase.md

Keybase proof

I hereby claim:

  • I am ryanmr on github.
  • I am ryanmr (https://keybase.io/ryanmr) on keybase.
  • I have a public key ASCn_b5Lvo--MjFb3wtRVQ3lbpaXc__Ivkw35xm3bLVQ4wo

To claim this, I am signing this object:

View chapters.py
import sys
from mutagen.id3 import ID3, CTOC, CHAP, TIT2, CTOCFlags
from mutagen import File
def main():
print "hi"
# target_file = "ns61-ian.mp3"
target_file = "pk43.mp3"
print_tags(target_file)
View Cards.scala
def split():(Deck, Deck) = {
val s = size()
val h = s / 2
val d1 = new Deck()
val d2 = new Deck()
for (i <- 1 to s) {
getCard() match {
case Some(card) => {
if (i < h) {
d1.addCard(card)
View evan-you-effect.js
document.addEventListener('touchmove', function (e) {
e.preventDefault()
})
var c = document.getElementsByTagName('canvas')[0],
x = c.getContext('2d'),
pr = window.devicePixelRatio || 1,
w = window.innerWidth,
h = window.innerHeight,
f = 90,
q,
View FeedsController.php
<?php
namespace App\Http\Controllers\Frontend;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use \Carbon\Carbon;
View query.txt
array:2 [▼
0 => array:3 [▼
"query" => "select * from `episodes` where (`hidden` = ? and `unlisted` = ? and `state` = ? and exists (select * from `series` where `episodes`.`series_id` = `series`.`id` and `slug` = ?) or exists (select * from `episodes_relations` as `self_a536d4a0691c58055cceecc94fd32e35` where `self_a536d4a0691c58055cceecc94fd32e35`.`episode_id` = `episodes`.`id` and `type` = ? and exists (select * from `series` where `episodes`.`series_id` = `series`.`id` and `slug` = ?) and `episodes`.`deleted_at` is null)) and `episodes`.`deleted_at` is null order by `published_at` desc, `created_at` desc"
"bindings" => array:6 [▼
0 => false
1 => false
2 => "published"
3 => "pk"
4 => "parent"
5 => "pk"
View episode-series-special.php
/*
Schema:
episodes (id, series_id, ...etc)
episode_relations (id, episode_id, episode_related_id)
series (id, slug, ...etc)
Some episodes are related to each other by the episodes_relations pivot table.
Goal:
get all of the episodes of the `specified-slug` series, and all of the episodes of `special-slug` that have a related parent episode that is in the `specified-slug` series
View episode_feed.php
$episodes = App\Episode::with(['related'])
->visible()
->recent()
->withSlug('pk')
->orWhere(function($query){
$query->withSlug('tf')->
whereHas('related', function($query){
$query->where('type', '=', 'parent')
->whereHas('related.series', function($query){
$query->where('slug', '=', 'pk');
View EpisodeWasCreated-ApplyEpisodeDefaults.md

A short story about a six month bug

I've been tinkering with Laravel for at least six months ago with a realistic goal of finishing a custom Nexus CMS before I expire of old age. A few months ago, I came around to adding the functionality for Episode events, specifically, applying default hosts and album art to an episode of none were specified when it was initally created -- short of a shortcut feature.

I will be addressing some classes (an Event, and a Listener, and below, a tiny fraction of the Episode model) from this gist published earlier. There might be some minor changes between this and production code, but it suffices.

    public function store(Request $request)
    {
You can’t perform that action at this time.