Skip to content

Instantly share code, notes, and snippets.

View AlephAlpha's full-sized avatar

AlephAlpha

View GitHub Profile
@emptymalei
emptymalei / Q
Last active June 28, 2016 01:35
Draft
好吧,本来我是想着我自己想起什么来就记上的,gist 这玩意也没法合作,所以就用评论吧。
1. 在自己公司自由的做科研的感受是什么?(跟大学比?)
2. 完全自由的 AI 的实现最大的障碍?
(* Conway's life rules *)
rule = {224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}};
(* hashlife algorithm *)
lastId = 1;
h[x_] := (lastId = lastId + 1; h[x] = lastId; q[lastId] = x; lastId);
q2[i_] := ArrayFlatten[Map[q, q[i], {2}]];
step[i_, d_] := step[i, d] = Block[{
i2 = q2[i],
half = Map[step[h[#], d - 1] &, Partition[#, {2, 2}, 1], {2}] &},
@vyznev
vyznev / hex2map.py
Last active July 28, 2020 12:01
Convert non-totalistic hexagonal CA rules to MAP rules
#!/usr/bin/python
"""
This script converts hexagonal isotropic (possibly non-totalistic) CA rules[1]
into the equivalent MAP rules[2]. It runs under both Python 2 and Python 3, and
can be used either as a stand-along script (with the rules given as command line
arguments) or as a Golly plug-in.
[1]: http://www.conwaylife.com/wiki/Isotropic_non-totalistic_Life-like_cellular_automaton#Hexagonal_neighbourhood
[2]: http://golly.sourceforge.net/Help/Algorithms/QuickLife.html
"""
@maksverver
maksverver / PKGBUILD
Created November 7, 2020 20:16
golly-4.0 PKGBUILD
# Maintainer: Kyle Sferrazza <kyle.sferrazza@gmail.com>
# Contributor: Maks Verver <maksverver@geocities.com>
# Contributor: p2k <Patrick.Schneider@uni-ulm.de>
# Contributor: nokangaroo <nokangaroo@aon.at>
pkgname=golly
pkgver=4.0
pkgrel=1
pkgdesc="A simulator for Conway's Game of Life and other cellular automata"
[
{
"src": "http://24.media.tumblr.com/tumblr_m1lew907mE1qejbiro1_1280.jpg",
"width": 600,
"height": 476
},
{
"src": "http://25.media.tumblr.com/Jjkybd3nSces6pgsQAXKUKjb_500.jpg",
"width": 500,
"height": 375
@veer66
veer66 / last_insert_rowid.rs
Created January 26, 2019 11:27
I tried to get last insert rowid from SQLite via Diesel. #rust
#[macro_use]
extern crate diesel;
pub mod models;
pub mod schema;
use diesel::prelude::*;
use diesel::sqlite::SqliteConnection;
use self::models::{Post, NewPost};
@shijinkui
shijinkui / basecommand_emacs
Created March 16, 2012 02:42
Emacs常用基本快捷键
/************************************/
基本命令
C-x C-f 打开/新建文件
C-x C-s 保存当前缓冲区
C-x C-w 当前缓冲区另存为
C-x C-v 关闭当前Buffer并打开新文件
C-x i 光标处插入文件
C-x b 切换Buffer
C-x C-b 显示Buffer列表
C-x k 关闭当前Buffer
@snoyberg
snoyberg / abonimable-snoyman.rs
Created December 2, 2020 15:05
Playing with GATs, transformers, and more
#![feature(generic_associated_types)]
#[allow(dead_code)]
trait Functor {
type Unwrapped;
type Wrapped<B>: Functor;
fn map<F, B>(self, f: F) -> Self::Wrapped<B>
where
F: FnMut(Self::Unwrapped) -> B;
@nixpulvis
nixpulvis / ping.rs
Created November 18, 2015 21:38
A simple Ping implementation in Rust.
#![feature(ip_addr, raw)]
extern crate pnet;
use std::net::{IpAddr, Ipv4Addr};
use pnet::transport::TransportChannelType::Layer4;
use pnet::transport::TransportProtocol::Ipv4;
use pnet::transport::transport_channel;
use pnet::packet::ip::IpNextHeaderProtocols;
use pnet::packet::Packet;