Skip to content

Instantly share code, notes, and snippets.

Avatar

Roger Stringer freekrai

View GitHub Profile
@freekrai
freekrai / log_js_errors.js
Created Mar 26, 2021 — forked from levelsio/log_js_errors.js
Log JS errors as a POST to your server
View log_js_errors.js
// <log errors to server>
window.onerror = function (messageOrEvent, source, lineno, colno, error) {
try {
console.log({
//error message(string).Available as event (sic!) in HTML onerror = "" handler.
messageOrEvent: messageOrEvent,
//URL of the script where the error was raised(string)
source: source,
//Line number where error was raised(number)
@freekrai
freekrai / app_GraphQL_schema.json
Created Mar 21, 2021 — forked from 4levels/app_GraphQL_schema.json
Sample setup Lighthouse with Lumen
View app_GraphQL_schema.json
# Just the basics: User with Images
scalar DateTime @scalar(class: "DateTime")
type User {
id: ID! @globalId
name: String
email: String
created_at: DateTime!
updated_at: DateTime!
@freekrai
freekrai / README.md
Created Mar 20, 2021 — forked from ppoffice/README.md
Install Visual Studio Code (actually code-server) on Android
View README.md
  1. Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.

  2. Update system packages in Termux:

    $ pkg update -y
@freekrai
freekrai / fauna-adapter.js
Created Nov 22, 2020 — forked from s-kris/fauna-adapter.js
faunadb adapter for next-auth for next.js
View fauna-adapter.js
// followed from next-auth repo: https://github.com/nextauthjs/next-auth
// create faunadb server key
// create collections: users, accounts, sessions, verificationRequests
// create required indexes
import faunadb, { query as q } from 'faunadb';
import { v4 as uuidv4 } from 'uuid';
import { createHash, randomBytes } from 'crypto';
@freekrai
freekrai / .zshrc
Created Nov 17, 2020 — forked from callumlocke/.zshrc
ZSH function to auto-switch to correct Node version
View .zshrc
####
# ZSH function to auto-switch to correct Node version
# https://gist.github.com/callumlocke/30990e247e52ab6ac1aa98e5f0e5bbf5
#
# - Searches up your directory tree for the closest .nvmrc, just like `nvm use` does.
#
# - If you are already on the right Node version, IT DOES NOTHING, AND PRINTS NOTHING.
#
# - Works correctly if your .nvmrc file contains something relaxed/generic,
# like "4" or "v12.0" or "stable".
View hash_djb2.php
<?php
function hash_djb2($str){
$hash = 5381;
$length = strlen($str);
for($i = 0; $i &lt; $length; $i++) {
$hash = ( ($hash << 5) + $hash ) + $str[$i];
}
return ($hash & 0xFFFFFFFF);
}
@freekrai
freekrai / notion2blog.js
Created Sep 16, 2020 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
View notion2blog.js
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@freekrai
freekrai / install_ffmpeg_ubuntu.sh
Created May 14, 2020 — forked from seankross/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
View install_ffmpeg_ubuntu.sh
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
View README.md

Build the application

go build -o queued *.go

Run the application

Now, to run our application, how about we start it with 2048 workers, just for kicks?

@freekrai
freekrai / NextValetDriver.php
Created Feb 23, 2019 — forked from james2doyle/NextValetDriver.php
A Laravel Valet driver for running generated Next.js sites. This driver assumes you have not changed the default public path (/out) in the next.config.js
View NextValetDriver.php
<?php
/**
* NextValetDriver for running compiled next.js sites
*/
class NextValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*