namerefs (introduced in bash 4.0) act as aliases for other variables
var=meow
declare -n ref=var
echo $ref # prints meow
ref=moo
echo $var # prints moo
namerefs (introduced in bash 4.0) act as aliases for other variables
var=meow
declare -n ref=var
echo $ref # prints meow
ref=moo
echo $var # prints moo
I have a pet project I work on, every now and then. CNoEvil.
The concept is simple enough.
What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?
#include <stdio.h> | |
#define SQ(x) (x)*(x) | |
#define M0(x,y) SQ(x)+SQ(y)<4?0:0xe0 | |
#define M1(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M0(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0)):0xc0 | |
#define M2(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M1(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0xa0 | |
#define M3(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M2(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x80 | |
#define M4(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M3(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x60 | |
#define M5(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M4(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x40 |
import numpy as n | |
def s(x):return 1.0/(1+n.exp(-x)) | |
def d(x):return x*(1.0-x) | |
class N: | |
def __init__(self,x,y):self.x,self.y=x,y;self.w1,self.w2,self.o=n.random.rand(self.x.shape[1],4),n.random.rand(4,1),n.zeros(self.y.shape) | |
def f(self):self.l1=s(n.dot(self.x,self.w1));self.o=s(n.dot(self.l1,self.w2)) | |
def b(self):r=n.dot(self.l1.T,(2*(self.y-self.o)*d(self.o)));q=n.dot(self.x.T,(n.dot(2*(self.y-self.o)*d(self.o),self.w2.T)*d(self.l1)));self.w1+=q;self.w2+=r | |
X=n.array([[0,0,1],[0,1,1],[1,0,1],[1,1,1]]);y=n.array([[0],[1],[1],[0]]);a=N(X,y) | |
for i in range(1500):a.f();a.b() | |
print(a.o) |
static void _buf_init(void **buf, int *cap, int elsize, const char *file, const int line) | |
{ | |
fprintf(stderr, "_buf_init(%p, %s, %d)\n", buf, file, line); | |
*buf = NULL; | |
*cap = 0; | |
} | |
static void _buf_reserve(void **buf, int *cap, int cnt, int elsize, const char *file, const int line) | |
{ | |
fprintf(stderr, "_buf_reserve(%p, %s, %d)\n", buf, file, line); |
Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it.
All I need to do is npm i -D webpack@next
, right?
+ [email protected]
In a project I'm working on I ran into the requirement of having some sort of persistent FIFO buffer or pipe in Linux, i.e. something file-like that could accept writes from a process and persist it to disk until a second process reads (and acknowledges) it. The persistence should be both across process restarts as well as OS restarts.
AFAICT unfortunately in the Linux world such a primitive does not exist (named pipes/FIFOs do not persist
#!/bin/bash | |
# | |
# Implementation of BASH + NCAT chat server | |
# | |
# Author: Anastas Dancha <[email protected]> | |
# Contact: [email protected] | |
# | |
#debug="true" |
#!/usr/local/bin/python3.2 | |
""" | |
Python interpreter for the esoteric language ><> (pronounced /ˈfɪʃ/). | |
Usage: ./fish.py --help | |
More information: http://esolangs.org/wiki/Fish | |
Requires python 2.7/3.2 or higher. |
;; outlet code for implementing traditional macro expansion | |
;; macros | |
(define (expand form) | |
(cond | |
((variable? form) form) | |
((literal? form) form) | |
((macro? (car form)) | |
(expand ((macro-function (car form)) form))) |