This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const io = std.io; | |
const assert = std.debug.assert; | |
// This example shows one possible way to approach Polymorphism in Zig | |
// using dynamic dispatch. | |
// | |
// Largely inspired by: | |
// - std/mem/Allocator.zig | |
// https://github.com/ziglang/zig/blob/77836e08a2384450b5e7933094511b61e3c22140/lib/std/mem/Allocator.zig#L55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Huffman Encoder/Decoder | |
# | |
# usage: | |
# To encode a string: | |
# > encode_string("foo foo bar") | |
# It returns an encoding table and the encoded text (TODO) | |
# | |
# https://engineering.purdue.edu/ece264/17au/hw/HW13?alt=huffman | |
TreeValue = Struct.new(:character, :frequency) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package amazon | |
import ( | |
"net/url" | |
"strings" | |
"fmt" | |
"regexp" | |
"time" | |
"crypto/hmac" | |
"crypto/sha256" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
METACLASS_TXT = """ | |
Hello, I am {} metaclass! | |
I am now creating '{}' class, child of '{}', | |
having the following class attributes: | |
{} | |
""" | |
class OCPRobotMeta(type): | |
def __new__(cls, name, bases, attrs): | |
"""new is called for the creation of a new class""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by | |
# Master NGINX - Dimitri Aivaliotis | |
# http://www.amazon.com/Mastering-NGINX-Dimitri-Aivaliotis-ebook/dp/B00B90PJR4 | |
# Chapter 8 - Switching binaries at runtime | |
# We get the pid of the 'to be replaced' nginx master process | |
export nginx_old_pid=`cat /var/run/nginx.pid` | |
# we send an USR2 signal to tell 'to be replaced' process | |
# to start a new master process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"flag" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
import tornado.auth | |
import tornado.gen | |
from tornado import escape, httpclient | |
from tornado.options import parse_command_line, define, options | |
try: | |
import urllib.parse as urllib_parse # py3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
import tornado.auth | |
import tornado.gen | |
from tornado.options import parse_command_line, define, options | |
define("port", default=8888) | |
define("debug", default=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
from tornado.options import parse_command_line, define, options | |
define("port", default=8888) | |
define("debug", default=False) | |
class AuthHandler(tornado.web.RequestHandler): | |
def get(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
from tornado.options import parse_command_line, define, options | |
define("port", default=8888) | |
define("debug", default=False) | |
class AuthHandler(tornado.web.RequestHandler): | |
def get(self): |
NewerOlder