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
jbnv / NameGenPostgreSQLEnglish.sql
Created June 2, 2015 01:07
Name Generator (PostgreSQL; English)
SELECT
arrays.firstnames[s.a % ARRAY_LENGTH(arrays.firstnames,1) + 1] AS firstname,
substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ' from s.a%26+1 for 1) AS middlename,
arrays.lastnames[s.a % ARRAY_LENGTH(arrays.lastnames,1) + 1] AS lastname
FROM generate_series(1,300) AS s(a) -- number of names to generate
CROSS JOIN(
SELECT ARRAY[
'Adam','Bill','Bob','Calvin','Donald','Dwight','Frank','Fred','George','Howard',
'James','John','Jacob','Jack','Martin','Matthew','Max','Michael',
'Paul','Peter','Phil','Roland','Ronald','Samuel','Steve','Theo','Warren','William',
@jbnv
jbnv / roam.css
Last active July 29, 2023 20:22
Stylesheet for Roam Research
/* Based on original Dark Age theme by @shodty */
/* MAIN BODY AND BLOCK COLORS */
.roam-body-main {
margin-top: 45px;
border-radius: 12px;
background: var(--background);
margin-right: 6px;
margin-left: 9px;
@jbnv
jbnv / DurandalVM.js
Created June 2, 2015 02:32
Durandal viewmodel template
define(['durandal/app', 'durandal/system', 'knockout'], function (app, system, ko) {
var data = ko.observableArray();
return {
data: data,
// Page events
activate: function () {
system.log('Lifecycle:activate');
},
@jbnv
jbnv / Calendar.sql
Created November 30, 2015 22:45
SQL Server [Calendar] view.
/*
A view that creates a view of date information, in a range from 2000 to 2179.
Use this view to perform date amd time operations would otherwise be difficult with standard T-SQL methods.
*/
CREATE VIEW [dbo].[Calendar]
AS
SELECT [Date]
,DATEPART(year,[Date]) AS [Year]
,DATEPART(month,[Date]) AS [Month]
,DATEPART(day,[Date]) AS [Day]
@jbnv
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
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() {
Vue.prototype.$message({
message: 'Copy successfully',
type: 'success',
duration: 1500,
});
}
@jbnv
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
jbnv / Basic Commands.md
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
jbnv / js.cson
Created September 11, 2017 18:06
Atom Snippets
'.source.js':
'alert':
'prefix':'//a'
'body': """
//BEGIN TEMP
alert($1);
//END TEMP
"""
'console.log':
'prefix':'//c'
@jbnv
jbnv / prompt.sh
Last active July 3, 2017 13:14
My standard shell prompt script. Show current git branch in the prompt, if there is one. Show current path in the prompt. Replace home path with "~". Replace "/var/www" with "%".
parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
parse_pwd () {
pwd | sed -e 's#/var/www/#%#' | sed -e 's#/home/myusername#~#'
}
prompt () {
echo "$BRANCH_COLOR\$(parse_git_branch)$USERNAME_COLOR`whoami`$PATH_COLOR\$(parse_pwd)$PROMPT_COLOR "