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
local http = require("socket.http") | |
local ltn12 = require("ltn12") | |
local base_url = "https://httpbin.org/" | |
function deep_print(tbl) | |
for i, v in pairs(tbl) do | |
if type(v) == "table" then | |
deep_print(v) | |
else |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
krace@hotbox /m/u/code> cat json_pg.py | |
import psycopg2 | |
def run(stmt): | |
cur = psycopg2.connect(database='test', user='postgres', password='password', host='localhost').cursor() | |
cur.execute(stmt) | |
result = cur.fetchall() | |
print(list(result)) |
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
;;; auto-remove.el --- Auto remove unused functions in python | |
;;; Commentary: | |
;; Uses external tool autoflake to remove unused imports from a Python file. | |
;;; Code: | |
(defcustom python-autoflake-path (executable-find "autoflake") | |
"Autoflake executable path. |
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
""" | |
Datastructures | |
1. Tuple | |
2. List | |
3. Set | |
4. Dictionary | |
5. Class | |
""" | |
import datetime |
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
Rust is a multi-paradigm, general-purpose programming language designed for performance and safety, | |
especially safe concurrency. | |
Rust is syntactically similar to C++, but can guarantee memory safety by using a borrow checker to validate references. | |
Rust achieves memory safety without garbage collection, and reference counting is optional. | |
Rust has been called a systems programming language and in addition to high-level features | |
such as functional programming it also offers mechanisms for low-level memory management. | |
First appearing in 2010, Rust was designed by Graydon Hoare at Mozilla Research, with contributions from | |
Dave Herman, Brendan Eich, and others. | |
The designers refined the language while writing the Servo experimental browser engine |
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
Python is an interpreted high-level general-purpose programming language. | |
Its design philosophy emphasizes code readability with its use of significant indentation. | |
Its language constructs as well as its object-oriented approach aim to help programmers write clear, | |
logical code for small and large-scale projects. | |
Python is dynamically-typed and garbage-collected. | |
It supports multiple programming paradigms, including structured (particularly, procedural), | |
object-oriented and functional programming. It is often described as a "batteries included" language | |
due to its comprehensive standard library. |
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
### Hash implementation in python | |
def custom_hash(key): | |
""" | |
Return the hash value of the given key. Uses dbj2 | |
@param key: String or unicode | |
""" | |
result = 5381 | |
multiplier = 33 |
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
# -*- coding: utf-8 -*- | |
import asyncio | |
import uvloop | |
from aiohttp.web import Application, MsgType, WebSocketResponse | |
def add_socket(app, socket, user_id): | |
if user_id in app['connections']: | |
pass |
NewerOlder