Skip to content

Instantly share code, notes, and snippets.

View joemccann's full-sized avatar
💭
Thinking

Joe McCann joemccann

💭
Thinking
View GitHub Profile
@joemccann
joemccann / nginx + node setup.md
Created October 25, 2010 02:06
Set up nginx as a reverse proxy to node.js.

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@joemccann
joemccann / async-google-font-loader.js
Created December 8, 2010 17:21
Async google font loader.
WebFontConfig = {
google: { families: [ 'Droid Sans' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
@joemccann
joemccann / convert.ts
Last active March 27, 2022 20:17
Convert Solana private key to array
import bs58 from 'bs58'
const bytes = bs58.decode('PRIVATE_KEY_HASH')
console.log(Array.from(bytes))
zo-keeper v0.1.0 (/Users/asymmetricholdingsltd./solana/liqudation-bots/01/zo-keeper)
├── anchor-client v0.21.0
│ ├── anchor-lang v0.21.0
│ │ ├── anchor-attribute-access-control v0.21.0 (proc-macro)
│ │ │ ├── anchor-syn v0.21.0
│ │ │ │ ├── anyhow v1.0.55
│ │ │ │ ├── bs58 v0.3.1
│ │ │ │ ├── heck v0.3.3
│ │ │ │ │ └── unicode-segmentation v1.9.0
│ │ │ │ ├── proc-macro2 v1.0.36
@joemccann
joemccann / install-evmos-on-macos.md
Created February 27, 2022 15:34
Quick and Dirty Gist to Install EVMOS on MacOS

Install EVMOS on MacOS

Install Go if you don't have it. Here's a quick guide.

Download the evmos binary:

Note depending on the release/version you'll need to update the version number and path of the tar file in the commands below. The version for this gist is v1.0.0-beta1/evmos_1.0.0-beta1_Darwin_arm64.tar.gz.

cd ~/Downloads/
@joemccann
joemccann / create_images_json_object_from_dir.js
Created January 14, 2011 21:17
Scan a directory and create a JSON object of images (and write it to a file) of all the images in that directory.
var sys = require("sys"),
fs = require("fs");
function processImageDir(path, outFilename, cb) {
fs.readdir(path, function(err, files) {
var imgfiles = [];
// Check for images and push on the array if it's a match.
files.forEach(function(name) {
#!/usr/bin/env zx
//
// Get array of lambda ARNs
//
let lambdas = JSON.parse(
await $`aws lambda list-functions --function-version ALL --output json --query "Functions[?Runtime=='nodejs10.x'].FunctionArn"`
)
//
@joemccann
joemccann / express-strap.md
Last active June 21, 2020 06:39
Boilerplate for creating an Express app using Boostrap
app="YOUR_APP_NAME"
mkdir $app
cd $app
git init
touch README.MD
echo "$app \n=\nWill add more info soon." >> README.MD 
sudo npm install -g express less uglify-js 
express --css less -e
mkdir vendor
@joemccann
joemccann / script.js
Created June 16, 2019 15:19
WebGL Smoke
var camera, scene, renderer,
geometry, material, mesh;
init();
animate();
function init() {
stats = new Stats();
stats.setMode(0);
stats.domElement.style.position = 'absolute';
@joemccann
joemccann / ocr.js
Created January 20, 2013 00:50
Optical Character Recognition with node.js and Tesseract. Check your console for the results...
var ncr = require('nodecr')
, request = require('request')
, fs = require('fs')
, test_img = 'https://www.google.com/images/srpr/logo3w.png' // Change this to your image
// Create image name from end of URL.
// Note this will fail in loads of cases.
var imgName = test_img.split('/').pop()
// Process the image and read the text from it using Tesseract