Skip to content

Instantly share code, notes, and snippets.

View ruffrey's full-sized avatar
🥦

ruffrey ruffrey

🥦
View GitHub Profile
@soypat
soypat / sleep.go
Created February 12, 2021 18:02
Cgo usleep vs. pure Go time.Sleep. Run with `go test -bench=.`
package ctest
// #include <time.h>
// void wait(int usec)
// {
// usleep(usec);
// }
import "C"
import "time"
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@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"
})
@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'; }
@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
@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
@karpathy
karpathy / min-char-rnn.py
Last active May 4, 2024 17:44
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)
@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
@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 }}"
@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active March 19, 2024 05:50
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):