Skip to content

Instantly share code, notes, and snippets.

View jbnv's full-sized avatar
Life is good.

Jay Bienvenu jbnv

Life is good.
View GitHub Profile
jbnv / roam.css
Last active July 29, 2023 20:22
Stylesheet for Roam Research
/* Based on original Dark Age theme by @shodty */
.roam-body-main {
margin-top: 45px;
border-radius: 12px;
background: var(--background);
margin-right: 6px;
margin-left: 9px;
jbnv / registerVueComponents.js
Last active June 17, 2020 13:54
Various functions associated with programming in Vue.
import Vue from '../app/mount.js';
import Clipboard from 'clipboard';
function clipboardSuccess() {
message: 'Copy successfully',
type: 'success',
duration: 1500,
jbnv / split.js
Created June 14, 2020 11:37
Node script to split a JSON file containing a single object into a folder of files.
const fs = require('fs');
const directory = process.argv[2];
fs.mkdir(directory, {
recursive: false
}, (err) => {
fs.readFile(`./${directory}.json`, 'utf8', (err, data) => {
if (err) throw err;
Object.entries(JSON.parse(data)).forEach(pair => {
const key = pair[0];
jbnv / Authenticate.php
Last active April 29, 2021 02:31
Debugging 401 Unauthorized on Laravel web/auth route
class Authenticate extends \Illuminate\Auth\Middleware\Authenticate
protected function redirectTo($request)
if (! $request->expectsJson()) {
return route('login');
jbnv / Basic
Last active January 12, 2018 16:28
Vim Quick Reference

Note: These apply to the Vim-Mode-Plus plugin for Atom and my custom keymaps. This is not a generic reference for Vim.

A "word" is an alphanumeric string. A "WORD" is any series of non-whitespace separated by whitespace.

  • a Append after cursor/at end of line.
  • b Previous word/WORD ("backword").
  • c Change. 🔠 Change to end of line.
  • d Delete. 🔠 Delete to end of line.
  • e End of word.
  • f
jbnv / js.cson
Created September 11, 2017 18:06
Atom Snippets
'body': """
jbnv / csv.php
Created February 15, 2017 17:09
Convert various list formats to arrays.
$csv = <<<CONTENT
$outbound = array();
foreach(explode("\n",$tsv) AS $line) {
$a = explode(",",$line);
$outbound[$a[0]] = $a[1];
jbnv / shim.php
Created February 3, 2017 22:15
Debugging shim for PHP.
echo '<p>['.__FILE__.':'.__LINE__.'] GOOD</p>';
try {
// some command here
} catch (Exception $e){
echo '<p>['.__FILE__.':'.__LINE__.'] DIE</p>';
jbnv / coalesce.php
Created February 3, 2017 21:48
Return the first value that isn't unset, null or empty.
// Return the first value that isn't unset, null or empty.
function coalesce() {
foreach(func_get_args() as $arg) {
if (!empty($arg)) return $arg;
return null;
jbnv / domino.js
Created September 13, 2016 14:19
Function to parse domino strings.
Given a string, representing domino tiles chain. Each tile has L-R format, where L and R are numbers from 1..6 range. Tiles are separated by the comma. Some examples of valid S chain are:
1. 1-4,4-2,3-1
2. 6-3
3. 4-3,5-1,2-2,1-3,4-4
Devise a function that, give a domino string, returns the number of tiles in the longest matching group within S. A matching group is a set of tiles that match and that are subsequent in S. Domino tiles match, if the right side of a tile is the same as the left side of the following tile. 2-4,4-1 are matching tiles, but 5-2,1-6 are not.
domino("1-1,3-5,5-2,2-3,2-4") should return 3.