Skip to content

Instantly share code, notes, and snippets.

View hushino's full-sized avatar
🇦🇷
Focusing

Hushino hushino

🇦🇷
Focusing
  • BotHub.moe
  • Cordoba, Argentina
  • 19:04 (UTC -03:00)
View GitHub Profile
@hushino
hushino / customcache.ts
Last active May 31, 2025 13:40
Drizzle + Redis Custom Cache
import { Table, is, getTableName } from "drizzle-orm";
import { Cache } from "drizzle-orm/cache/core";
import type { CacheConfig } from "drizzle-orm/cache/core/types";
import { createClient, type RedisClientType } from "redis";
// Initialize Redis client
export const redis: RedisClientType = createClient({
url: "redis://localhost:6379",
});
redis.connect().catch((err) => console.error("Redis connection error:", err));
@hushino
hushino / app.js
Created March 13, 2021 05:03 — forked from johnnybui/app.js
Node.JS - Import Data From Cloud Firestore Into Elasticsearch
const admin = require('firebase-admin');
const elasticsearch = require('elasticsearch');
// Config before running
const CONFIG = {
limit: 1000, // reduce if got Deadline exceeded error
index: 'stock',
type: 'doc',
dev: {
serviceAccountJson: './devServiceAccount.json',
@hushino
hushino / fastmap.js
Last active March 12, 2019 12:58
fastmap
function arrayClone(arr) {
var len = arr.length;
var copy = new Array(len);
for (var i = 0; i < len; i++) {
copy[i] = arr[i];
}
return copy;
}
@hushino
hushino / mongodb-raw.js
Created February 7, 2019 19:45
A very high performance up to 160k/s
const h = require('../helper');
const async = require('async');
const MongoClient = require('mongodb').MongoClient;
const collections = {
World: null,
Fortune: null
};
MongoClient.connect('mongodb://tfb-database/hello_world?maxPoolSize=5', (err, db) => {
// do nothing if there is err connecting to db
@hushino
hushino / trap.js
Created February 6, 2019 23:30
manage objects/arrays with map and reduce
function merge(arr1, arr2){
const arr1ById = arr1.reduce((map, next) => (map[next.id] = next, map), {});
const byId = arr2.reduce((map, next) => (map[next.id] = next,map), arr1ById);
//const byId = arr2.reduce((map, next) => arr1ById);
// resta el 2do elemento arr[1]
//return Object.entries(byId).map((arr) => arr[1]);
var asd = Object.entries(byId).map((arr) => arr[1]);
return asd[1].total;
}
// actualiza valores teniendo en cuenta el id
@hushino
hushino / pom.xml
Created February 5, 2019 22:15
maven target java 1.8
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ato</groupId>
<artifactId>mix</artifactId>
<version>1.0-SNAPSHOT</version>
@hushino
hushino / pom.xml
Created October 1, 2018 12:59
A GRPC CONFIGURATION
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>red</groupId>
<artifactId>d</artifactId>
<version>1.0-SNAPSHOT</version>