Skip to content

Instantly share code, notes, and snippets.

from collections import deque
import curses
import time
import random
#random.seed(1)
class Snake:
def __init__(self, width, height, stdscr):
self.width = width
#!/bin/bash
message () {
ans=$(zenity --entry --title="It's time!" --timeout=86000 --text="$current_message"s)
if [ "$ans" != "123" ]
then
sleep 1m
message
else
end_time=$(date -u)
touch buffer
import os
import time
import signal
def timestr(seconds):
if seconds >= 60:
return '%0.0f minutes %0.0f seconds' % (seconds//60, seconds % 60)
else:
return str(int(seconds)) + ' seconds'
#ifndef ARCPLACER_H
#define ARCPLACER_H
#include <math.h>
#define loopy(i, n) for(unsigned int i = 0; i < n; i++)
static inline float posMod(float a, float n){
return a - n * floor(a/n);
}
void SensorySystem::update() {
loopy(i, subSNumber){
subSystems[i]->sense();
}
if(centralTileSensor.enabled) centralTileSensor.sense(body->GetPosition());
}
void SensorySystem::draw ( NVGcontext* vg ) {
loopy(i, subSNumber){
struct CanBeSensed{
uint16 senseMask;
//id for unordered_map inside sensors
static IdInt idCountS;
CanBeSensed(uint16 _senseMask): idS (++idCountS),
senseMask(_senseMask){}
IdInt getIdS() const { return idS; };
struct Base{
virtual float getDistance() = 0;
};
struct CanBeSmelled{
Smell smells[10];
Smell getSmell();
};
struct CanBeHeard{
Sound sounds[10];
Sound getSound();
@avasilkov
avasilkov / qqq.cpp
Last active January 16, 2016 19:18
struct Sensor{
void sense(CanBeSensed* o){
for(int i = 0; i< 1000000; i++){
for(int j = 0; j< 1000000; j++){
float value = o->getSound(); or o->getSmell();
std::cout<<value<<std::endl;
}
}
}
@avasilkov
avasilkov / time.cpp
Last active December 23, 2015 08:39
long long int getTime(timeval* tp){
gettimeofday(tp, nullptr);
return tp->tv_sec * 1000 + tp->tv_usec / 1000;
}
int main (int argc, char *argv[])
{
struct timeval tp;
long int n = 1000000L;
std::vector<unsigned long int> idx;
import numpy as np
def sig(z):
return 1/(1 + np.exp(-z))
def sig_der(output):
return output*(1 - output)
and_ = 0
if and_: