Skip to content

Instantly share code, notes, and snippets.

@aelaguiz
aelaguiz / ctransformers_embeddings.py
Created December 20, 2023 03:56
Langchain + CTransformers embedding function
from langchain_community.llms.ctransformers import CTransformers
from langchain_core.embeddings import Embeddings
from typing import List
import asyncio
class CTransformersEmbeddings(Embeddings):
def __init__(self, llm):
self.llm = llm
@aelaguiz
aelaguiz / CratejoyIsHiring.js
Last active September 22, 2023 15:08
Cratejoy (YC S13) - Hiring a killer JS Front-End Engineer to build v4 of our website builder
// CratejoyIsHiring.js
define(['backbone', 'underscore'], function(Backbone, _) {
var CratejoyJavascriptJob = {
needs: {
'Rebuild our website builder': {
description: 'Website builder is on v3, you\'ll build v4',
requirements: [
'Easy to use for non-technical people',
'Powerful enough for design agencies',
const solana = require('@solana/web3.js');
const splToken = require('@solana/spl-token');
const mplTokenMetadata = require("@metaplex-foundation/mpl-token-metadata");
const metaplex = require('@metaplex/js');
const key = require('./key.json');
const run = async() => {
const kp = solana.Keypair.fromSecretKey(Buffer.from(key));
const connection = new solana.Connection(
@aelaguiz
aelaguiz / gist:864454
Created March 10, 2011 16:58
node.js function to create full directory path (like mkdir -p)
exports.createFullPath = function createFullPath(fullPath, callback) {
var parts = path.dirname(path.normalize(fullPath)).split("/"),
working = '/',
pathList = [];
for(var i = 0, max = parts.length; i < max; i++) {
working = path.join(working, parts[i]);
pathList.push(working);
}
@aelaguiz
aelaguiz / gist:4455549
Last active October 8, 2016 15:13
Quick & Dirty Theano benchmark
import numpy
import theano
import theano.tensor as T
import config
import time
def theano_softmax():
x = T.fmatrix('x')
_y = T.nnet.softmax(x)
<ul class="list-group">
<li class="list-group-item"><h4>Your Subscription(s)</h4></li>
{% set exists = [] %}
{% for sub in customer.subscriptions %}
{% if sub.store_id == store.id %}
{# This makes sure we know if we found a sub tied to the store #}
{% do exists.append(1) %}
@aelaguiz
aelaguiz / gist:8386014
Created January 12, 2014 15:28
weird behavior of relpath
Python:
os.chdir(path)
cwd = os.getcwd()
print path
print cwd
print os.path.relpath(path, start=cwd)
output:
./themes/bold
@aelaguiz
aelaguiz / dispatching_model.py
Created November 28, 2013 13:22
Dispatching model pattern with sqlalchemy
import sqlalchemy as sqla
import sqlalchemy.ext.declarative as decl
from .signals import signaler
class _hooked(object):
def __init__(self, validate_func, normalize_func, field_name, private_name):
self.validate_func = validate_func
self.normalize_func = normalize_func
self.field_name = field_name
@aelaguiz
aelaguiz / theano_softmax
Last active December 10, 2015 15:19
Equivalent straight numpy/python for Theanos softmax function
import numpy
import theano
import theano.tensor as T
def theano_softmax():
x = T.dmatrix('x')
_y = T.nnet.softmax(x)
f = theano.function([x], _y)
return f
@aelaguiz
aelaguiz / client.js
Created February 28, 2011 16:55
Communications for chat client using message.socket.io
var ChatRoom = function ChatRoom(chatList, inputArea, list) {
var _chatList = chatList,
_inputText = inputArea,
_userList = list,
_nickList = [];
/*
* Handle three events from the communications layer
*/
this.expose = {