This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use faiss::{error::Error, index_factory, Index, MetricType}; | |
fn main() -> Result<(), Error> { | |
let my_data = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; | |
let mut index = index_factory(8, "Flat", MetricType::L2)?; | |
index.add(&my_data)?; | |
let result = index.search(&my_data, 5)?; | |
for (i, (l, d)) in result | |
.labels | |
.iter() | |
.zip(result.distances.iter()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(warnings)] | |
use std::{collections::HashMap, convert::Infallible, sync::Arc}; | |
use tokio::sync::RwLock; | |
use warp::{Filter, Rejection}; | |
fn with_store( | |
store: Arc<RwLock<HashMap<String, u64>>>, | |
) -> impl Filter<Extract = (Arc<RwLock<HashMap<String, u64>>>,), Error = Infallible> + Clone { | |
warp::any().map(move || store.clone()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(warnings)] | |
use std::{collections::HashMap, convert::Infallible, str::FromStr, sync::Arc}; | |
use tokio::sync::RwLock; | |
use warp::{Filter, Rejection}; | |
fn with_store( | |
store: Arc<RwLock<HashMap<String, u64>>>, | |
) -> impl Filter<Extract = (Arc<RwLock<HashMap<String, u64>>>,), Error = Infallible> + Clone { | |
warp::any().map(move || store.clone()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def permutations(to_go, path_taken='', paths=[]): | |
if not to_go: | |
print(path_taken) | |
paths.append(path_taken) | |
else: | |
for i in range(len(to_go)): | |
here = to_go[i] | |
elsewhere = to_go[:i] + to_go[i+1:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cjson = require "cjson" | |
ngx. req. read_body() -- explicitly read the req body | |
local data = ngx. req. get_body_data() | |
local jsonBody = cjson. decode(data); | |
if data then | |
local reqs = { } | |
--ngx. say("body data:") | |
for key, value in pairs(jsonBody) do | |
--ngx.print(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a script to load seshat data into Elasticsearch | |
# seshat data is clearly graphdb data, but ES is nifty, so... | |
# assumes you have set up elasticsearch and kibana | |
import pandas as pd | |
from elasticsearch import Elasticsearch | |
from elasticsearch.helpers import parallel_bulk | |
# assumes local ES | |
es = Elasticsearch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a version of 'Learning from Clicks' in 'Programming Collective | |
# Intelligence' p74, a pdf is online at the below url | |
# https://github.com/ShawnLeee/the-book/blob/master/pybooks/Programming%20Collective%20Intelligence.pdf | |
# | |
# This is a fully connected network stored in sqlite, so, yeah, not for Production. :) | |
from math import tanh | |
from timeit import default_timer as timer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# http://unix.stackexchange.com/questions/230238/starting-x-applications-from-the-terminal-and-the-warnings-that-follow | |
export NO_AT_BRIDGE=1 | |
WALLPAPERS="/home/alex/Dropbox/backgrounds" | |
ALIST=( `ls -w1 $WALLPAPERS` ) | |
RANGE=${#ALIST[@]} | |
let "number = $RANDOM" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file has been auto-generated by i3-config-wizard(1). | |
# It will not be overwritten, so edit it as you like. | |
# | |
# Should you change your keyboard layout some time, delete | |
# this file and re-run i3-config-wizard(1). | |
# | |
# i3 config file (v4) | |
# | |
# Please see http://i3wm.org/docs/userguide.html for a complete reference! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Unmap capslock | |
clear Lock | |
keycode 66 = Hyper_L | |
! | |
! leave mod4 as only super | |
remove mod4 = Hyper_L | |
! | |
add mod3 = Hyper_L |