Skip to content

Instantly share code, notes, and snippets.

@ahmed-anas
ahmed-anas / llama-with-chrome.py
Created February 29, 2024 05:46
Lamma index with chroma tutorial
# Some of the code in this file has been adapted from the llama index tutorial.
# Import necessary libraries and modules
import os.path
import chromadb
from llama_index.vector_stores.chroma import ChromaVectorStore
from llama_index.core import StorageContext
from llama_index.llms.openai import OpenAI
from llama_index.core import (
@ahmed-anas
ahmed-anas / README.md
Created October 2, 2020 13:39
CR M1 - Refactor to an Angular Component - Integration Guide

Note: this is a public version for the following file (which may be moved to master soon): https://github.com/trilogy-group/devfactory-coderamp/blob/milestone/CR-1048-Refactor-to-an-Angular-Component/projects/coderamp-lib/README.md

Integration Guide

Dependencies required

See the peerDependencies key in the package.json for coderamp-lib (i.e projects/coderamp-lib/package.json) to view all the dependencies needed in the parent project to be able to properly use coderamp-lib.

Installing the library

  1. Run npm run pack:lib to generate a coderamp-lib-<version>.tgz file in the dist/coderamp-lib directory.
  2. Copy this file to the root of any angular project you want to integrate it into.
  3. In the root of that angular project, run npm install coderamp-lib-.tgz (replacing `` with the version of the file).
@ahmed-anas
ahmed-anas / readwrite.js
Created April 10, 2020 17:46
quick scripts
//https://gist.github.com/andreruffert/f4d0dd7385e2735eca93
const fs = require('fs');
const readline = require('readline');
const readFile = readline.createInterface({
input: fs.createReadStream('file.in'),
output: fs.createWriteStream('file.out'),
terminal: false
});
#for Mysql 8.0.1 onwards
#see: https://dev.mysql.com/doc/refman/8.0/en/data-locks-table.html
SELECT * from performance_schema.data_locks;
@ahmed-anas
ahmed-anas / sequelize-to-ts.js
Created February 25, 2020 05:06
sequelize to typescript
const fs = require('fs');
const Sequelize = require('sequelize');
let Path = require('path');
const _ = require('lodash');
const OUTPUT_FOLDER ='generated-ts-files';
@ahmed-anas
ahmed-anas / Install NVIDIA Driver and CUDA.md
Last active March 26, 2018 07:22 — forked from zhanwenchen/Install NVIDIA Driver and CUDA.md
Install NVIDIA CUDA 8.0 on Ubuntu 16.04.3 LTS
@ahmed-anas
ahmed-anas / custom_bind.js
Created February 11, 2017 04:44
a basic implementation of bind without various properties
let myObj = {
str: 'Original Scope',
foo: function() {
console.log(`my scope is ${this.str}.`);
}
}
function myBind(func, scope){
for(let prop in scope){
@ahmed-anas
ahmed-anas / exp_backoff_ping.js
Created February 11, 2017 04:15
semi-pseudo exponential backoff service in javascript
function expBackoffService(uri, base, tryCount, startTime){
tryCount = tryCount || 0; //tryCount is optional
base = base || 2; //exponential base is optional, defaults to 2
startTime = startTime || (new Date()).getTime();
let elapsedTime = ((new Date()).getTime() - startTime)/1000;
console.log(`pinging for the ${tryCount} time, at ${elapsedTime} seconds`);
let timeoutDuration = Math.pow(tryCount, base) * 1000;