Skip to content

Instantly share code, notes, and snippets.

View rnd-forests's full-sized avatar

Vinh Nguyen rnd-forests

View GitHub Profile
@rnd-forests
rnd-forests / PjaxMiddleware.php
Created October 11, 2015 19:45 — forked from JeffreyWay/PjaxMiddleware.php
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@rnd-forests
rnd-forests / belongs-to-many.sublime-snippet
Created June 19, 2016 17:33 — forked from adamwathan/belongs-to-many.sublime-snippet
Eloquent Relationship snippets for Sublime Text
<snippet>
<content><![CDATA[
public function ${1:relationship}()
{
return \$this->belongsToMany(${1/^(.+)$/(?1\u$1:)/g}::class, {$2:table});
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>belt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"es6": true,
"amd": true,
"jquery": true,
@rnd-forests
rnd-forests / stack-auth-bounce.js
Created April 13, 2017 10:15 — forked from therealplato/stack-auth-bounce.js
Bouncing a user back to their last place after authentication with Express 3
// Bouncing a user back to their last place after authentication with Express 3
// To accompany http://stackoverflow.com/a/12443844/1380669
// by therealplato
var express = require('express');
var app = express();
require('http').createServer(app).listen(3000
, function(err){
console.log(err || "Listening on 3000");
});
[
// Remove HTML tags
'/<(.*?)>/' => "$1",
// Remove setext-style headers
'/^[=\-]{2,}\s*$/m' => '',
// Remove footnotes?
'/\[\^.+?\](\: .*?$)?/m' => '',
'/\s{0,2}\[.*?\]: .*?$/' => '',
// Remove images
// '/!\[([^\[]+)\]\(([^\)]+)\)/' => '$1',
@rnd-forests
rnd-forests / videojs.js
Created July 8, 2017 12:48
Video.js directive for Vue.js
import Vue from 'vue'
import _assign from 'lodash/assign'
import _isEqual from 'lodash/isEqual'
const videojs = window.videojs = require('video.js')
const defaults = {
poster: '',
fluid: true,
sources: [],
muted: false,
@rnd-forests
rnd-forests / svd.py
Last active June 9, 2020 10:52
SVD++ Recommendations
from __future__ import absolute_import, division, print_function, \
unicode_literals
import os
import math
import pprint
import datetime
import numpy as np
from timeit import default_timer
from collections import defaultdict
@rnd-forests
rnd-forests / Slimdown.md
Created August 7, 2017 01:25 — forked from jbroadway/Slimdown.md
Slimdown - A simple regex-based Markdown parser.

Slimdown

A very basic regex-based Markdown parser. Supports the following elements (and can be extended via Slimdown::add_rule()):

  • Headers
  • Links
  • Bold
  • Emphasis
  • Deletions
@rnd-forests
rnd-forests / api-docs.html
Created September 20, 2017 06:26
Viblo Machine Learning API Documentation
<!DOCTYPE HTML><html><head><title>Viblo Machine Learning API documentation</title><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="generator" content="https://github.com/raml2html/raml2html 6.4.1"><link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/default.min.css"><script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script><script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script><script type="text/javascript">
$(document).ready(function() {
$('.page-header pre code, .top-resource-description pre code, .modal-body pre code').each(function(i, block) {
hljs.high