Skip to content

Instantly share code, notes, and snippets.

View netoxico's full-sized avatar
🏠
Working from home

Ernesto Vargas netoxico

🏠
Working from home
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@netoxico
netoxico / example.md
Created August 21, 2024 02:55 — forked from wiseman/example.md
Get store hours from images
$ python hours.py image.jpg
{
  "day_hours": [
    {
      "day": "Mon - Fri",
      "hours": "7 AM - 5 PM"
    },
    {
 "day": "Saturday",
@netoxico
netoxico / function.js
Created February 24, 2024 03:42 — forked from czue/function.js
OpenAI function for Source Citations in a RAG architecture
{
"name": "answer_and_sources",
"description": "Gets an answer and cites the relevant sources used to provide the answer.",
"parameters": {
"type": "object",
"properties": {
"answer": {
"type": "string",
"description": "The answer to the user's question.",
},
@netoxico
netoxico / K8s-DigitalOcean-CoreOS.md
Created September 26, 2018 03:24 — forked from kevashcraft/K8s-DigitalOcean-CoreOS.md
How to Setup Kubernetes on DigitalOcean with CoreOS

Kubernetes on DigitalOcean with CoreOS

Let's look at an example of how to launch a Kubernetes cluster from scratch on DigitalOcean, including kubeadm, an Nginx Ingress controller, and Letsencrypt certificates.

Overview

Environment

We'll be creating a four-node cluster (k8s-master, k8s-000...k8s-002), load balancer, and ssl certificates.

Table of Contents

  1. Install Kubernetes
@netoxico
netoxico / sudoku_seeds.txt
Created December 6, 2015 22:27 — forked from ndrwhr/sudoku_seeds.txt
10,000, certified organic, sudoku seed puzzles. Made in Brooklyn, NY.
381562479527491638964873521293154867718326954645987312872645193436719285159238746
157864392942573816863912754429751683716328945385649127571496238234187569698235471
219764385347958621865132974436285197921473568578619432694527813182346759753891246
342587619985461237176293485268945371531876942497132568719324856853619724624758193
173854629682179534954263781315928476298746315746531892531697248469382157827415963
481596237523748169697231854735189642862475913914362785356827491179654328248913576
754689123162453798398127465413896257527314689689275314231548976876932541945761832
356197842184625937792834516678243159925781364413569278867312495539478621241956783
815764923732519846649823751276485139453971268981236574524698317368157492197342685
472953861159486732836271495917865324648132579523749186391527648785694213264318957
@netoxico
netoxico / bookmarklet.js
Created November 24, 2015 17:02 — forked from poteto/bookmarklet.js
Converts a HTML table with `thead` and `tbody` into an array of objects. You can then use JSON.stringify(json) or copy(json) to your clipboard.
javascript:void%20function(){(function(t){t.extend(t.fn,{tableToJSON:function(){var%20n=this,r=t(%22thead%20th%22,n).map(function(n,r){return%20t(r).text().trim().toLowerCase()});return%20t(%22tbody%20tr%22,n).map(function(n,e){var%20o=t(e),a={};return%20t(%22td%22,o).each(function(n,e){var%20o=r[n];a[o]=t(e).text().trim()}),a}).toArray()}})})(jQuery)}();
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()
@netoxico
netoxico / The Technical Interview Cheat Sheet.md
Last active August 25, 2015 23:51 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this
// you cannot send image data as part of a multipart/form-data encoded request from
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to
// find yet another way to implement this. (This is left as an exercise for the reader,
// but if you do it, please let me know and I'll integrate it.)
// from: http://stackoverflow.com/a/5303242/945521
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) {