Skip to content

Instantly share code, notes, and snippets.

View ukchukx's full-sized avatar
💭
Unus sed leo

Uk ukchukx

💭
Unus sed leo
View GitHub Profile
@ukchukx
ukchukx / uuid.js
Created January 17, 2018 22:41 — forked from duzun/uuid.js
A simple UUID v4 generator, relying on Math.random() + Date.now()
/** Generates UUID v4
*
* @node There is a bug in Chrome's Math.random() according to http://devoluk.com/google-chrome-math-random-issue.html
* For that reason we use Date.now() as well.
*/
function UUID() {
function s(n) { return h((Math.random() * (1<<(n<<2)))^Date.now()).slice(-n); }
function h(n) { return (n|0).toString(16); }
return [
s(4) + s(4), s(4),
@ukchukx
ukchukx / readme.md
Created September 30, 2019 13:38 — forked from maxivak/readme.md
Restore repo from Gitlab bundle file

Gitlab exports repositories to tar archive which contains .bundle files.

We have repo.bundle file and we want to restore files from it.

  • create bare repo from bundle file
git clone --mirror myrepo.bundle my.git
@ukchukx
ukchukx / stream_chat_kong_1.sh
Created January 21, 2020 19:17
Steps to running Kong using Docker
docker network create kong-net
docker run -d --name kong-database --network=kong-net \
-p 5432:5432 -e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" postgres:9.6
docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
kong:latest kong migrations bootstrap
$ mkdir -p kongchat/{frontend,backend}
$ cd kongchat/backend
$ touch index.js
$ npm init -y
$ npm i express body-parser dotenv stream-chat ip
require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const ip = require('ip');
const { StreamChat } = require('stream-chat');
const app = express();
// Add the middlewares
app.use(bodyParser.json());
KC_STREAM_CHAT_KEY=xxxx
KC_STREAM_CHAT_SECRET=xxxx
{
"scripts": {
"start": "node index.js"
},
}
FROM node:carbon-alpine
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 10000
CMD ["npm", "start"]
version: '3'
services:
kc_backend:
build: ./backend
image: kc_backend
container_name: kc_backend
network_mode: kong-net
$ docker network inspect kong-net
# Sample output
[
{
"Name": "kong-net",
"Id": "1176776a97a0d22a44789cdd8fb4408cb80e4af086ac6474ab503704fda06c40",
# ...
"Containers": {
# ... "3a21018c6c9a6c0877ac182e7cd0e3e3da0af87b36d1f2a4882f76fe43a03a27": {
"Name": "kc_backend",