Skip to content

Instantly share code, notes, and snippets.

View rozag's full-sized avatar

Alexey Mileev rozag

  • Earth
View GitHub Profile
@rozag
rozag / gist:9305233
Last active August 29, 2015 13:56
Написать рекурсивную программу, которая печатает по одному разу все k^n последовательностей длины n, составленные из чисел 1...k. Аналогичный код на C++: https://gist.github.com/Rozag/9305260
(defun generate (n k p)
(cond ((eq p n)
(cond ((eq count 1)
(loop for i from 0 to (- n 1)
do (format t "~D" (+ (elt arr i) 1)))
(format t "~%")))
(cond ((< count k) (setq count (+ count 1)))
(T (setq count 1))))
(T (loop for i from 0 to (- k 1)
@rozag
rozag / gist:9305260
Last active August 29, 2015 13:56
Написать рекурсивную программу, которая печатает по одному разу все k^n последовательностей длины n, составленные из чисел 1...k.
#include <iostream>
using namespace std;
void generate(int n, int k, int p) {
static int a[1000000];
static int tmp = 1;
if (p == n) {
if (tmp == 1) {
@rozag
rozag / gist:9625066
Last active August 29, 2015 13:57
Глупейшая сортировка. Случайным образом свапает два элемента и проверят пока не посортится. Уже на 13 работает долго :)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <vector>
#include <set>
#include <ctime>
using namespace std;
private static final int SECOND_MILLIS = 1000;
private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
private static final int DAY_MILLIS = 24 * HOUR_MILLIS;
public static String getTimeAgo(long time, Context context) {
if (time < 1000000000000L) {
// if timestamp given in seconds, convert to millis
time *= 1000;
}
@rozag
rozag / Notificator.java
Last active August 29, 2015 14:13
A simple class for Android local notifications.
public class Notificator {
public static Notification with(final Context context) {
return new Notification(context);
}
public static class Notification {
private final Context mContext;
@rozag
rozag / EloquentLife.js
Last active August 29, 2015 14:15
My Electronic Life implementation for Eloquent JavaScript book
"use strict";
var MAX_CYCLES = 5;
var ACTING_ENERGY_LOSSES = 2;
var START_PLANT_ENERGY = 30;
var PLANT_REPRODUCTION_ENERGY = 10;
var PLANT_INCOMING_ENERGY = 2;
@rozag
rozag / index.html
Last active February 4, 2021 18:09
Простой фрактал на JavaScript
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>SimpleFractal</title>
</head>
<body>
<canvas width="900" height="600"></canvas>
</body>
@rozag
rozag / index.html
Last active August 29, 2015 14:18
Conway's Game of Life
<!doctype html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Game of Life</title>
</head>
<canvas></canvas>
<script src="main.js"></script>
@rozag
rozag / KTouch-Slava-Kochetkov-RU.xml
Created November 1, 2016 14:54
Курс русской печати для KTouch от Славы Кочеткова, который я адаптировал к новой версии KTouch.
<?xml version="1.0"?>
<course>
<id>{d8abcd0f-44a9-44ab-b6a3-e06908041b7b}</id>
<title>Русская by Slava Kochetkov</title>
<description>Writing by Slava Kochetkov (slava@rejik.ru)</description>
<keyboardLayout>ru</keyboardLayout>
<lessons>
<lesson>
<id>{08ca1f8d-6ddc-4c50-a0ad-d3979b7716cf}</id>
<title>Level 1</title>
@rozag
rozag / keybase.md
Created April 19, 2017 15:50
Verifying myself on keybase.io

Keybase proof

I hereby claim:

  • I am rozag on github.
  • I am rozag (https://keybase.io/rozag) on keybase.
  • I have a public key ASARItueGmMr-u_4jpmjgnAWrp82xuI_vKQztwqAK3KADAo

To claim this, I am signing this object: