Skip to content

Instantly share code, notes, and snippets.

View ruffrey's full-sized avatar
🥦

Jeff P ruffrey

🥦
View GitHub Profile
@chris-rock
chris-rock / crypto-stream.js
Last active October 6, 2022 18:38
Encrypt and decrypt streams
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption of buffers
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
var fs = require('fs');
var zlib = require('zlib');
@raykendo
raykendo / ArcGIS-JSAPI-MapClickByQueryHack.md
Last active July 6, 2018 20:29
ArcGIS-JSAPI: Clicking on a webmap without clicking on a webmap

Clicking on a map without clicking on a map

An ArcGIS JavaScript API hack

Purpose: I have a map application with a list of results from a query. When I click on one of the items in the result list, I wanted the map to zoom to the associated feature, and trigger a click that shows the result in a popup.

Library: ArcGIS JavaScript API

Version: tested on versions 3.9-3.13.

@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active June 7, 2024 05:09
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@iAugur
iAugur / ansible-ip-list-play.yml
Last active August 22, 2021 13:09
Ansible: Example of working with lists of host vars
---
- hosts: servers
gather_facts: true
sudo: true
vars:
fail2ban_config_ignoreip:
- "127.0.0.1/8"
- "{{ ansible_ssh_host }}"
@varemenos
varemenos / 1.README.md
Last active April 21, 2024 23:21
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@karpathy
karpathy / min-char-rnn.py
Last active June 9, 2024 20:26
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@chadxz
chadxz / Chrome 46 WebRTC Renegotiation Issues.md
Last active December 16, 2015 15:39
Chrome 46 WebRTC Renegotiation Issues

Chrome 46 WebRTC Renegotiation Issues

The below SDP is recreated using the following steps:

  • Participant A offers audio+video to Participant B
  • B answers with audio+video
  • Call connected.
  • A renegotiates to remove audio, making it a video-only call from it's side
    • calls getUserMedia with { audio: false, video: true }
  • removes all streams from the peer connection, and adds the stream from getUserMedia
@leedm777
leedm777 / WebRTC-Standards.md
Last active December 4, 2015 19:52
If you start digging into WebRTC, here's all the stuff you'll run into
@davidfurlong
davidfurlong / Bookshelf-postgis.md
Last active February 28, 2022 05:47
Use Bookshelf with postgis and knex-postgis without the hassle

How to use Bookshelf with postgis and knex-postgis without the hassle

Using Bookshelf.js with postgis and knex-postgis is a huge pain in the ass.

TLDR - Override Bookshelf methods to parse postgis formats in JS, not in SQL to avoid having to do awkward Bookshelf modifications anywhere you make a bookshelf insert/update/delete on Geo data (middleware like approach)

class Event extends Bookshelf.Model {
  get tableName() { return 'event'; }
@zimmicz
zimmicz / server.js
Created August 6, 2017 16:25
PostGIS MVT Express routing
const express = require("express")
const app = express()
const { Pool } = require("pg")
const SphericalMercator = require("sphericalmercator")
const pool = new Pool({
host: "localhost",
port: 15432,
user: "postgres",
database: "postgres"
})