Skip to content

Instantly share code, notes, and snippets.

View ferronrsmith's full-sized avatar
⛱️
Chilling on the beach

Ferron H ferronrsmith

⛱️
Chilling on the beach
View GitHub Profile
@ferronrsmith
ferronrsmith / querysets.md
Created October 8, 2023 19:53 — forked from onlyphantom/querysets.md
QuerySet API Reference (with code examples)

QuerySet API reference (stock portfolio example)

An in-depth guide to Django QuerySet (Django 3.0, updated June 2020).

When QuerySets are evaluated

Internally, a QuerySet can be constructed, filtered, sliced, and generally passed around without actually hitting the database. No database activity actually occurs until you do something to evaluate the queryset. Examples of that "something" that cause a QuerySet to evaluate:

  1. Iteration: QuerySet executes its database query the first time you iterate over it
    for q in Quote.objects.all():
        print(q.symbol)
@ferronrsmith
ferronrsmith / crack_navicat.sh
Created September 30, 2023 22:43 — forked from Archaeoraptor/crack_navicat.sh
用于Archlinux的Navicat Premium 15 破解安装脚本,已经废弃,请谨慎使用,请自行承担任何后果
#!/bin/bash
set -xeuo pipefail
echo "Crack Navicat15, works on Arch based Distro....."
echo "安装破解的一切后果请自行承担"
echo "由于版权原因本脚本不再维护,推荐使用DBeaver等开源替代或使用mycli、pgcli等终端工具,或使用教育邮箱或开源贡献认证申请Jetbrains家的DataGrip"
source /etc/os-release
case $ID in
arch)
@ferronrsmith
ferronrsmith / runserver.py
Created September 11, 2023 04:41 — forked from piotrkilczuk/runserver.py
Run multiple instances of Django development server using subprocesses
#!/usr/bin/env python
import glob
import os.path
import socket
import subprocess
import sys
# manage.py must be made executable in order for this to work
@ferronrsmith
ferronrsmith / LICENSE.txt
Created July 11, 2023 06:13 — forked from chrisevans/LICENSE.txt
tofu: tiny templating engine
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Haochi Chen <http://ihaochi.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@ferronrsmith
ferronrsmith / prim_second.md
Created April 6, 2023 23:49 — forked from softwaredoug/prim_second.md
Additive vs Multiplicative Boosting Solr & Elasticsearch

Ramblings for Relevant Search. Primary and Secondary ranking factors in relevance. Problem: you want to rank with two factors. Simply multiplying scores ignores the relative significance of the primary/secondary scores. For example, in the tables below, if the first column is much more important to ranking than the second factor. The second factor is more of a tie breaker for ties in the primary criteria. Additive boosting seems to do a better job at this:

Additive Boosting

Primary Secondary Sum
10 0.9 10.9
10.1 0.7 10.8
10 0.8 10.8
@ferronrsmith
ferronrsmith / compare_solr_boosts.py
Created April 6, 2023 23:36 — forked from nolanlawson/compare_solr_boosts.py
Script for comparing the different ways of "boosting" queries in Solr
#!/bin/sh/env python
#
# Simple script for comparing the various ways of "boosting" queries in Solr,
# combined with the three main query parsers (lucene, dismax, and edismax).
# The idea is to generate md5sums of the search results, so I can quickly
# figure out which boost methods work the same as the other ones.
#
import re, urllib2, urllib, md5, json
// Refrence http://stackoverflow.com/questions/18817336/golang-encrypting-a-string-with-aes-and-base64
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
@ferronrsmith
ferronrsmith / TikaExtractor.java
Created January 6, 2023 04:03 — forked from LorisBachert/TikaExtractor.java
Using Apache TIKA to extract the following formats: DOC, DOCX, PPT, PPTX, XLS, XLSX, PDF, JPG, PNG, TXT Note: Tesseract must be installed in order to get JPG and PNG extraction working.
/**
* Uses Tikas {@link AutoDetectParser} to extract the text of a file.
*
* @param document
* @return The text content of a file
*/
@Override
public String extractTextOfDocument(File file) throws Exception {
InputStream fileStream = new FileInputStream(file);
Parser parser = new AutoDetectParser();
// This is a minimal Base64 encode/decode utility for Nashorn -> JavaScript
// Add error checking for data types as needed within encode or decode
var Base64 = {
decode: function (str) {
return new java.lang.String(java.util.Base64.decoder.decode(str));
},
encode: function (str) {
return java.util.Base64.encoder.encodeToString(str.bytes);
}
};
@ferronrsmith
ferronrsmith / docker-nfs-volumes.md
Created September 12, 2019 14:23 — forked from ruanbekker/docker-nfs-volumes.md
NFS Volumes with Docker Swarm

Create NFS Volumes:

Creating the NFS Volume:

$ docker volume create --driver local \
  --opt type=nfs \
  --opt o=addr=192.168.1.115,uid=1000,gid=1000,rw \
  --opt device=:/mnt/volumes/mysql-test \
  mysql-test-1