Skip to content

Instantly share code, notes, and snippets.

Avatar

Pavel Kulyov pkulev

View GitHub Profile
View boom.lisp
(defpackage :dat-application
(:use :cl)
(:export #:application))
(in-package :dat-application)
(defvar *application*)
(defclass application ()
((data :initform 0)))
@pkulev
pkulev / pkg
Created May 30, 2019
Yasnippet for creating elisp package. Place it to ~/.emacs.d/snippets/emacs-lisp-mode/pkg. `user-full-name` and `user-mail-address` should be defined.
View pkg
# -*- mode: snippet -*-
# name: Generate elisp package
# key: pkg
# --
;;; ${1:package-name}.el --- ${2:Description}.
;; Copyright (C) `(sixth (decode-time (current-time)))` `(user-full-name)`
;; Author: `(user-full-name)` <`user-mail-address`>
;; Maintainer: `(user-full-name)` <`user-mail-address`>
@pkulev
pkulev / _reader-macros.md
Created Apr 25, 2018 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp
View _reader-macros.md

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@pkulev
pkulev / o-notation.md
Last active Apr 2, 2018
Efficiency and Orders of Growth
View o-notation.md

Efficiency and Orders of Growth

Measuring complexity:

  • time
  • memory

Mesuring base steps

  • use a random access machine as model of computation
  • steps are executed sequentially
View main.cpp
#include <map>
#include <iostream>
using namespace std;
class NetworkInterface {
public:
int a = 5;
@pkulev
pkulev / GravityJump.cs
Created Jan 15, 2018
Not physically ideal but good jump
View GravityJump.cs
using UnityEngine;
using System.Collections;
public class GravityJump : MonoBehaviour {
public float fallMultiplier = 2.5f;
public float lowJumpMultiplier = 2f;
Rigidbody2D rb;
View server.py
import argparse
import socket
import logging
import threading
LOG = logging.getLogger(__name__)
"""Logger instance."""
DEBUG = False
View tactical_reload.py
# -*- coding: utf-8 -*-
T_TRIGGER_ACTION_MANUAL = "manual action"
T_TRIGGER_ACTION_SINGLE = "single action"
T_TRIGGER_ACTION_DOUBLE = "double action"
T_AMMO_9x18gzh = "9x18gzh"
T_AMMO_9x19para = "9x19para"
T_AMMO_45ACP = ".45ACP"
View pseudogame.cpp
//---------------------------------------------------------------------------
#pragma hdrstop
#include <tchar.h>
#include <iostream>
#include <conio.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
typedef short unsigned int SUINT;
View db.py
""" """
# Tuple functions
def append(tup, elem): return tup + (elem,)
def ainit(length, func):
return reduce(append, map(func, range(length)), ())