Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Delikat delikat

View GitHub Profile
View rn.py
# database.py
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
# models.py
from database import db
class Request(db.Model):
# ...
@delikat
delikat / next.config.js
Last active Aug 4, 2021
Modular antd imports with next.js, next-less, next-typescript, and babel-plugin-import
View next.config.js
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'}
@delikat
delikat / next.config.js
Created Jun 10, 2018
Modular antd imports with next.js, next-less, and next-typescript
View next.config.js
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 / optimizely_secure_webhooks.py
Created Jul 13, 2017
An extremely simple Flask app that accepts Optimizely webhook requests and verifies their signatures
View optimizely_secure_webhooks.py
# 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'])
View keybase.md

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 / bitwisequeens.js
Created Oct 3, 2013
bitwise n-queens solution
View bitwisequeens.js
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);
@delikat
delikat / spiralTraversal.js
Created Sep 13, 2013
rotation-based array spiral traversal
View spiralTraversal.js
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];
}