Skip to content

Instantly share code, notes, and snippets.

View r0yfire's full-sized avatar

Roy Firestein r0yfire

View GitHub Profile
@willurd
willurd / web-servers.md
Last active May 16, 2025 10:42
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@plentz
plentz / nginx.conf
Last active May 3, 2025 05:27
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@jedisct1
jedisct1 / demo.txt
Last active December 27, 2015 17:48
security graph intersect API
1) Start with only one known domain from a botnet: qwmrxczhrcmbcagehqwxlvsnj.ru
2) Get the intersection of names looked up by the IPs having looked up this domain. It takes less than 1 minute.
$ curl https://sgraph.umbrella.com/dnsdb/clientlookups/i/name/qwmrxczhrcmbcagehqwxlvsnj.ru | sort -rn > /tmp/a
3) Remove popular domains
cut -f2 /tmp/a | filter-popular > /tmp/aa
@branneman
branneman / better-nodejs-require-paths.md
Last active May 15, 2025 11:17
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@thoop
thoop / nginx.conf
Last active April 14, 2025 17:11
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
@revolunet
revolunet / python-es6-comparison.md
Last active April 11, 2025 10:54
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math
@karpathy
karpathy / min-char-rnn.py
Last active May 12, 2025 17:28
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)
@nakedible-p
nakedible-p / proxy.js
Created October 19, 2015 19:55
AWS ES proxy
var AWS = require('aws-sdk');
var http = require('http');
var httpProxy = require('http-proxy');
var express = require('express');
var bodyParser = require('body-parser');
var stream = require('stream');
if (process.argv.length != 3) {
console.error('usage: aws-es-proxy <my-cluster-endpoint>');
process.exit(1);
@notpeelz
notpeelz / crawler.js
Last active May 26, 2021 16:27
Visa requirements Wikipedia crawler
import Crawler from 'crawler';
import url from 'url';
const BASE_ADDRESS = 'https://en.wikipedia.org/';
const COUNTRY_PATTERN = /.*?Visa_requirements_for_(.*?)_citizens.*?/i;
const VISA_REQUIRED_PATTERN = /.*?visa\s+required.*?/i;
const VISA_NOT_REQUIRED_PATTERN = /.*?visa\s+not\s+required.*?/i;
const visaRequirements = {};
@dannguyen
dannguyen / README.md
Last active September 10, 2024 19:41
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs