Skip to content

Instantly share code, notes, and snippets.

View Inviz's full-sized avatar

Yaroslaff Fedin Inviz

View GitHub Profile
# Subquery that finds user data, happens for every resource request
# Also takes (and decodes) flash message from get parameters
eval $meta {
set_unescape_uri $flash $arg_flash;
postgres_pass database;
postgres_output json;
postgres_query "SELECT 'user name' as biggles, nullif('$flash', '') as flash";
postgres_rewrite GET no_rows 403;
}
var values = [];
var open = 0;
var value
var character;
for (a in $r.args) {
// sort params in array
for (n = 0; n < values.length; n++) {
#include <stdio.h>
#include <string.h>
int array_push_sorted(char *array[128], int size, char *string, int length) {
int j, k;
char *old;
for (j = 0; j < size; j++ ) {
old = array[j];
int i = 0;
--- a/nginx/ngx_http_js_module.c Thu Apr 14 18:23:09 2016 +0300
+++ b/nginx/ngx_http_js_module.c Wed May 04 16:46:03 2016 +0800
@@ -95,6 +95,8 @@
njs_value_t *value, void *obj, uintptr_t data);
static njs_ret_t ngx_http_js_ext_get_remote_address(njs_vm_t *vm,
njs_value_t *value, void *obj, uintptr_t data);
+static njs_ret_t ngx_http_js_ext_get_var(njs_vm_t *vm,
+ njs_value_t *value, void *obj, uintptr_t data);
static njs_ret_t ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value,
void *obj, uintptr_t data);
-- Example of a postgre-driven immutable versioned and validated models
DROP TABLE orders CASCADE;
CREATE TABLE orders(
id serial, -- Serial ID
root_id integer, -- ID of a first version
parent_id integer, -- ID of a previous version
version integer, -- Version number
errors jsonb, -- Results of validation
var level = "\
= = == = \
~~-~~-~~-~~-~\
\
= \
\
X ";
var map = level.split("\n");
@Inviz
Inviz / noise shader.js
Last active December 20, 2015 16:59
Noise shader rewritten in js
}
function snoise(vx, vy)
{
// const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
// 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
// -0.577350269189626, // -1.0 + 2.0 * C.x
// 0.024390243902439); // 1.0 / 41.0
decoration:
connector:
optional: true
$ii:
Y_inversion:
inverted:
place: [['graphical'], ['end']]
uninverted:
place: [['graphical'], ['start']]
@Inviz
Inviz / CSS debate.md
Last active December 15, 2015 10:59

Which way to go?

The best way write CSS and HTML is to properly use all the techniques that are available to us.

Introduction

CSS has "cascading" in it's name. It means that stylesheets may define rules that propagate to all the nodes in the hierarchy. It's a powerful system that sometimes may get pretty messy. If selectors are too specific, then there's a lot of code duplication. If selectors are too generic, then there're lots a of conflicts. The smart way to do it is to find balance.

class EntriesController < ApplicationController
def index
@entries = scope
end
def show
@entry = scope.first
end
def scope