Skip to content

Instantly share code, notes, and snippets.

Error: could not connect to ollama app, is it running?
ssanyam-macbookpro:~ ssanyam$ ollama serve
2023/12/15 18:44:35 images.go:779: total blobs: 15
2023/12/15 18:44:35 images.go:786: total unused blobs removed: 0
2023/12/15 18:44:35 routes.go:777: Listening on 127.0.0.1:11434 (version 0.1.11)
[GIN] 2023/12/15 - 18:44:50 | 200 | 166.791µs | 127.0.0.1 | HEAD "/"
[GIN] 2023/12/15 - 18:44:50 | 200 | 1.642208ms | 127.0.0.1 | POST "/api/show"
2023/12/15 18:44:50 llama.go:420: starting llama runner
2023/12/15 18:44:50 llama.go:478: waiting for llama runner to start responding
{"timestamp":1702694691,"level":"INFO","function":"main","line":1324,"message":"build info","build":219,"commit":"9e70cc0"}
@siddhant3s
siddhant3s / Main.java
Created December 11, 2020 21:45
javaget: A simple java program to fetch a page from the internet
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL(args[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
function my_new_recipie(har) {
if (har.log.entries[0].time > 3) {
return { status: false, errors: ['Too big']};
}
return {status: true};
}
function verify_har(har) {
if (har.log) {
return {
status: false,
errors: [
'Too many 403 errors found',
],
};
}
return {status: true};
function verify_har(har) {
if (!har.log) {
return {
status: false,
errors: [
'HAR file should have a logs section.',
],
};
}
if (!har.log.entries) {
@siddhant3s
siddhant3s / bankers.py
Created December 27, 2013 12:38
Banker's Safety Algorithm.
from operator import add, sub, le
def vector(operator):
'''
Apply operator to each element of vector and returns
the resultant vector:
from operator import add, sub, mul
vector(add)([1,2,3], [2,3,4]) => [3,5,7]
'''
return lambda A, B: map(operator, A, B)
@siddhant3s
siddhant3s / rsa_simple.py
Last active December 31, 2015 10:08
A very simple, inefficient and insecure implementation of RSA just for educational purpose. Only for learning how RSA works. On a usual implementation you would put conditions on the primes generated as suggested by the inventors of RSA (like they shouldn't be too close etc.). To study RSA, you can read from a textbook like one by William Stalli…
import random
def isProbablePrime(n):
'''
Miller-Rabin primality test.
from http://rosettacode.org/wiki/Miller-Rabin_primality_test#Python
'''
_mrpt_num_trials = 5 # number of bases to test
assert n >= 2
# special case 2
if n == 2:
@siddhant3s
siddhant3s / QueuingTheory.py
Created May 28, 2013 20:08
Models M/M/1 Queue. Return some userful results, can be (should be) used as a module. simple_mm1 is an example of using QueuingTheory.
from scipy.stats import expon
from scipy import cumsum,maximum,empty,insert
def getRandomArrivalServiceTimes(n_process, arrival_rate, service_rate):
time_intervals = expon.rvs(scale = 1/arrival_rate, size = n_process - 1)
arrival_times = insert(cumsum(time_intervals), 0, 0)
service_times = expon.rvs(scale = 1/service_rate, size = n_process)
return arrival_times, service_times
def mm1(arrival_times, service_times):
n_process = arrival_times.size
@siddhant3s
siddhant3s / hotpo.cpp
Created September 25, 2011 15:10
uVA 3n+1 problem
/* Comment next line if your implementation doesn't support TR1
It will then use STL's map instead of TR1's unordered_map,
thus will be a little slow (map take worst case log(N) access time)
If you don't care about memory, the solution can be sped up using arrays
instead of std::map
*/
#define TR1
#include <iostream>
#ifdef TR1
"loadDocument": function (doc_id, handler ) {
/*
Calls handler with an object associated with requested document of the `doc_id`
The first argument of handler is error object or null depending on if error occured or not.(Like NodeJS)
Second argmuent is the object literal containing
.hash of the object is the MD5 hash of the data