Skip to content

Instantly share code, notes, and snippets.

View dlitvakb's full-sized avatar

David Litvak Bruno dlitvakb

View GitHub Profile
class MyTest
include Mini::Unit
def test_foo
assert(2, 1)
end
end
MyTest.run!
@dlitvakb
dlitvakb / astar.py
Created October 7, 2015 21:54
AStar structured version
from __future__ import print_function
import random
import math
BLOCKED = u'\u2588'
EMPTY = " "
START = "A"
FINISH = "B"
require 'netdnarws'
api = NetDNARWS::NetDNA.new("alias", "key", "secret")
certData = File.read('/path/to/ssl/demo.crt')
certKeyData = File.read('/path/to/ssl/demo.key')
api.post("/zones/pull/{zoneid}/ssl.json", {'ssl_crt' => certData,'ssl_key' => certKeyData})

RFC 3986: Web Encoding Hell

Have you ever had problems with %20 vs + spacing encoding when using external HTTP APIs? We've faced this problem, multiple times. Our own REST API faced this problem. But don't be afraid, there's a reason for it, and there are plenty of solutions out there.

So, what is RFC 3986?

RFC 3986 is the URI (Unified Resource Identifier) Syntax document, in this document you can find with very profound detail everything you will ever want to know about how URIs should be written and how they should be read.

But, if there's a detailed specification, what's the problem with it?

In the last couple of years, modern web browsers have been pushing towards more compact URI schemes. So every modern web browser encodes spaces as + instead of %20, while every other character is still encoded using Percent Encoding.

class Jugador(object):
def __init__(self, nombre, sexo):
self.nombre = nombre
self.sexo = sexo
if __name__ == '__main__':
jugadores = []
cantidad_jugadores = int(raw_input('Ingrese la cantidad de jugadores: '))
for x in xrange(cantidad_jugadores):
@dlitvakb
dlitvakb / php_pullzone.php
Created November 12, 2012 17:31
Python, Ruby and PHP Pull Zone Creation for NetDNA's RWS
<?php
require_once('NetDNA.php');
$api = new NetDNA("my_alias", "0de95ee2fa4138252c1e431c177ac14904feb56f7", "9553c35f1656f51a0e8940baff71414f");
$api->post('/zones/pull.json', array('name' => 'my_pullzone', 'url' => 'pull.mydomain.com'));
?>

New NetDNA REST API Clients

On a previous post we've talked abut our new REST API and the benefits it provides to our power users. If that was not enough for your satisfaction, we are releasing REST Clients for Python and Ruby to help you use our service without having to worry about anything.

Forget about OAuth problems

from netdnarws import NetDNA
from funkload.FunkLoadTestCase import FunkLoadTestCase
from unittest import main
from test_data import test_data
class BenchmarkTest(FunkLoadTestCase):
def setUp(self):
self.api = NetDNA("cdnintegration",
@dlitvakb
dlitvakb / ex.py
Created August 13, 2012 03:28 — forked from anonymous/ex_py
Pruebas
ex_or = 0
while True:
num=raw_input('Ingrese el numero 1: ')
num2=raw_input('Ingrese el segundo numero 2: ')
if len(num) == len(num2):
for indice, letra in enumerate(num):
if letra == num2[indice]:

New NetDNA REST API Clients

On a previous post we've talked abut our new REST API and the benefits it provides to our power users. If that was not enough for your satisfaction, we are releasing REST Clients for Python and Ruby to help you use our service without having worry about anything.

Forget about OAuth problems