Skip to content

Instantly share code, notes, and snippets.

@skanga
skanga / llama.cpp.bat
Created February 7, 2024 20:46
Build llama.cpp with OpenBLAS on Windows
:: ========================================
:: BUILD LLAMA.CPP WITH OPENBLAS ON WINDOWS
:: ========================================
set BASE_DIR=c:\bin
mkdir %BASE_DIR%
mkdir c:\tmp
cd c:\tmp
@skanga
skanga / java-llama.cpp.txt
Created February 7, 2024 20:20
Build java-llama.cpp on Windows
:: Install JDK & add to path - https://www.oracle.com/java/technologies/downloads/
:: Install Maven & add to path - https://maven.apache.org/download.cgi
:: Install Cmake & add to path - https://cmake.org/download/
:: Install w64devkit & add to path - https://github.com/skeeto/w64devkit/releases
:: Install Windows SDK - https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/
set W64DEVKIT=c:\bin\w64devkit
set JAVA_HOME=c:\java\jdk-11.0.16.1
set PATH=%JAVA_HOME%\bin;%W64DEVKIT%\bin;%PATH%
@skanga
skanga / ollama.txt
Created February 6, 2024 05:12
Build & Run ollama on Windows 11
BUILD (See https://github.com/jmorganca/ollama/blob/main/docs/development.md)
=============================================================================
:: Downloaded golang 1.21 from https://go.dev/dl/go1.21.6.windows-amd64.zip and add to PATH
:: Downloaded mingw64 and installed in \bin\mingw64
c:\bin\mingw64\env.bat
cd %USERPROFILE%
git pull https://github.com/jmorganca/ollama
cd ollama
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

Setup TOR on Ubuntu

# Install TOR and some other needed dependencies:
sudo apt-get install -y tor curl netcat

# Stop service (if running):
/etc/init.d/tor stop

# Create torrc file
// It requires jsoup.jar (from https://jsoup.org/download) in the classpath
// It needs to parameters on command line:
// 1. The github url to be downloaded
// 2. The local directory where the downloaded files should be stored
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@skanga
skanga / SimpleHttpServer.java
Created May 11, 2020 19:54
Socket based web server in around 200 lines using pure JDK classes only without com.sun.* classes. Features include file server, dir listing, multithreading, access logging, etc.
import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.text.*;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.concurrent.*;
@skanga
skanga / opencv-install.sh
Created March 25, 2020 14:10
Build OpenCV (with Java) from git sources on Ubuntu Linux
# Install OS tools needed for the build
sudo apt-get -y update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev ant default-jdk
# Detect the default java home and set the env var for it
export JAVA_HOME=$(java -XshowSettings:properties -version 2>&1 > /dev/null | awk -F' ' '/java.home/ {print $3}')
export ANT_HOME=/usr/bin/ant
git clone https://github.com/opencv/opencv
cd opencv/
@skanga
skanga / InsecureSSL.java
Created June 21, 2019 16:57
Make SSL connections using HttpsURLConnection when certificates cannot be validated (self-signed certs) and/or the hostname cannot be validated (ssh tunnels, etc)
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
@skanga
skanga / clock.html
Created February 18, 2019 21:02
Analog + Digital Clock (using SVG, CSS & JS) that scales to any screen size
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Scalable Analog + Digital Clock (using SVG, CSS & JS)</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}