Skip to content

Instantly share code, notes, and snippets.

View delikat's full-sized avatar

Andrew Delikat delikat

View GitHub Profile
@delikat
delikat / spiralTraversal.js
Created September 13, 2013 16:24
rotation-based array spiral traversal
var spiralTraversal = function(matrix){
var width = matrix[0].length - 1;
var height = matrix.length;
var newMatrix = [];
var firstRow = matrix[0];
if (matrix.length === 1) {
return matrix[0];
}
@delikat
delikat / bitwisequeens.js
Created October 3, 2013 03:49
bitwise n-queens solution
var bitwiseCountNQueensSolutions = function(n) {
var solutions = 0;
var allBits = Math.pow(2, n) - 1;
var bitwiseQueens = function(majorDiag, col, minorDiag) {
var poss = ~(majorDiag | col | minorDiag) & allBits;
while (poss) {
var queenSpot = -poss & poss;
poss = poss ^ queenSpot;
bitwiseQueens((majorDiag | queenSpot) >> 1, col | queenSpot, (minorDiag | queenSpot) << 1);

Keybase proof

I hereby claim:

  • I am delikat on github.
  • I am delikat (https://keybase.io/delikat) on keybase.
  • I have a public key whose fingerprint is 0A1D 2349 B7B1 CEDC BBD6 1568 04A3 F9A2 2559 1EC7

To claim this, I am signing this object:

@delikat
delikat / optimizely_secure_webhooks.py
Created July 13, 2017 19:06
An extremely simple Flask app that accepts Optimizely webhook requests and verifies their signatures
# Example Flask implementation of secure webhooks
# Assumes webhook's secret is stored in the environment variable WEBHOOK_SECRET
from hashlib import sha1
import hmac
import os
from flask import Flask, request, abort
@app.route('/webhooks/optimizely', methods=['POST'])
@delikat
delikat / next.config.js
Created June 10, 2018 23:51
Modular antd imports with next.js, next-less, and next-typescript
const withLess = require('@zeit/next-less')
const withTypescript = require('@zeit/next-typescript')
const resolve = require('resolve')
module.exports = withTypescript(withLess({
lessLoaderOptions: {
javascriptEnabled: true,
// place antd theme overrides here
modifyVars: {'@primary-color': '#1Dd57A'}
},
@delikat
delikat / next.config.js
Last active August 4, 2021 03:39
Modular antd imports with next.js, next-less, next-typescript, and babel-plugin-import
const withLess = require('@zeit/next-less')
const withTypescript = require('@zeit/next-typescript')
const resolve = require('resolve')
module.exports = withTypescript(withLess({
lessLoaderOptions: {
javascriptEnabled: true,
// theme antd here
modifyVars: {'@primary-color': '#1Dd57A'}
# database.py
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
# models.py
from database import db
class Request(db.Model):
# ...