Skip to content

Instantly share code, notes, and snippets.

View jdcrensh's full-sized avatar

Jon Crenshaw jdcrensh

View GitHub Profile
@jdcrensh
jdcrensh / retropie-notes.md
Last active February 14, 2019 22:53
[Retropie Notes] #retropie

Retro gaming Raspberry Pi

There are many ways to build one, but this is mine!

Note that my build uses RetroPie, which is a highly configurable system. However, there could be a learning curve. This is especially true if you're not familiar with Linux or using the command line when you get into trouble. So keep that in mind! RetroPie is backed by a huge community, so help is usually just a Google search away.

Here's an alternate guide, but I only really used it to help me with overclocking so I could

@jdcrensh
jdcrensh / _service.md
Created April 10, 2018 07:42 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
.mtk4 {
font-style: italic;
}
@jdcrensh
jdcrensh / auto_git_file.md
Created November 30, 2017 22:40 — forked from darencard/auto_git_file.md
Automatic file git commit/push upon change

Automatically push an updated file whenever it is changed

Linux

  1. Make sure inotify-tools is installed (https://github.com/rvoicilas/inotify-tools)
  2. Configure git as usual
  3. Clone the git repository of interest from github and, if necessary, add file you want to monitor
  4. Allow username/password to be cached so you aren't asked everytime
git config credential.helper store
@jdcrensh
jdcrensh / harden.sh
Created December 3, 2016 22:58 — forked from jumanjiman/harden.sh
hardening script for an alpine docker container
#!/bin/sh
set -x
set -e
#
# Docker build calls this script to harden the image during build.
#
# NOTE: To build on CircleCI, you must take care to keep the `find`
# command out of the /proc filesystem to avoid errors like:
#
# find: /proc/tty/driver: Permission denied
@jdcrensh
jdcrensh / LimitProfilingCallout.cls
Last active July 21, 2016 00:07
[apex] Same-instance callouts provide separate transactions
@RestResource(urlMapping = '/LimitProfiling/*')
global with sharing class LimitProfilingCallout {
@HttpPost
global static void callMeMaybe() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Map<String, Object> data = (Map<String, Object>) JSON.deserializeUntyped(req.requestBody.toString());
@jdcrensh
jdcrensh / zipdir.js
Created May 27, 2016 23:06
[node.js] Archive (zip) files within directory
const streamBuffers = require('stream-buffers');
const archiver = require('archiver');
const zipDir = (dir) => {
const output = new streamBuffers.WritableStreamBuffer({
initialSize: (100 * 1024), // start at 100 kilobytes.
incrementAmount: (10 * 1024), // grow by 10 kilobytes each time buffer overflows.);
});
const archive = archiver('zip');
archive.on('end', () => {
@jdcrensh
jdcrensh / StringBuilding.cls
Created May 6, 2016 17:51
Profiling of String concatenation and the StringBuilder pattern in Apex (Salesforce)
/**
* Compares String concatenation performance vs StringBuilder.
* At around 21000 iterations, actual time spent is nearly identical. At higher iterations,
* StringBuilder comes out ahead in less actual time spent and with lower CPU usage. However in
* lower iterations, concatenation wins both measurements.
*
* Another consideration is that the StringBuilder pattern does not seem to affect the heap
* size limit at all, which could be a bug with Apex profiling.
*/
@jdcrensh
jdcrensh / example.js
Created May 2, 2016 23:21
Using SweetAlert2 with Webpack
var sweetAlert = require('sweetalert2');
sweetAlert('Hello World!', 'It works!', 'success');
@jdcrensh
jdcrensh / Base62.java
Last active January 28, 2024 12:25
Class to encode a string into base 62 (character set [a-zA-Z0-9]) with Java. A common use case is URL shortening.
public class Base62 {
public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public static final int BASE = ALPHABET.length();
private Base62() {}
public static String fromBase10(int i) {
StringBuilder sb = new StringBuilder("");