Skip to content

Instantly share code, notes, and snippets.

View cray0000's full-sized avatar
🚀

Pavel Zhukov cray0000

🚀
View GitHub Profile
@cray0000
cray0000 / snippets.json
Last active January 30, 2022 20:59
Startupjs snippets for VS Code
{
"Console Log": {
"prefix": "log",
"body": "console.log($1)"
},
"import {} from 'react-native'": {
"prefix": "irn",
"body": "import { $1 } from 'react-native'"
},
"import {} from 'components'": {
FROM ubuntu:21.04
WORKDIR /ws
ENTRYPOINT [ "bash" ]
@cray0000
cray0000 / gist:a78c3c01775fb53f4dbd3d10fa939aac
Created July 24, 2019 19:39
bash. Clear terminal after each command.
# add it to ~/.bash_profile
# Clear terminal before each command execution
preexec () {
echo -e "\033];$1\007";
echo -e "\033[1;34m------------------------------------------------------------------------------------------------\033[0m";
clear;
echo -e "\033[1;34m$1\033[0m";
}
preexec_invoke_exec () {
@cray0000
cray0000 / remove_backend_service.sh
Created July 2, 2019 18:15
Delete gcloud backend-services
# This might be needed in future in case backend-services are not getting
# deleted automatically. It was an issue with the earlier Ingress versions.
# Lately though, it seems like Ingress handles the deletion automatically well.
function removeBackendService {
local appLabel=$1
local services=($( gcloud compute backend-services list --global --project=$PROJECT | awk 'NR>1 {print $1}' ))
local service
for service in "${services[@]}" ; do
echo "Testing service $service"
gcloud compute backend-services describe $service --global --project=$PROJECT \
@cray0000
cray0000 / example.sh
Created December 25, 2018 14:49
cron example alpine
docker run --rm alpine /bin/sh -c "echo '* * * * * /bin/echo RunJob' > /etc/crontabs/root && crond -f"
@cray0000
cray0000 / 0_SharedbWithHooks.js
Last active November 16, 2018 18:31
react-sharedb HOOKS
import React from 'react'
import {useDoc, useQuery, useLocal, useValue, useSubscribe} from 'react-sharedb'
export function Simple ({gameId}) {
let [game, $game] = useDoc('games', gameId)
if (!game) return null // <Loading />
function updateGameTitle (event) {
$game.set('title', event.target.value)
}
@cray0000
cray0000 / one_line_node_server.sh
Created September 18, 2018 10:58
Simplest one line "hello world" Node.js server running on port 3000
node -e "require('http').createServer((_, res) => res.end('hello world')).listen(3000)"
@cray0000
cray0000 / Docker_Usage.md
Last active October 11, 2018 19:31
Docker usage cheat sheet (only the most useful stuff)

Docker Usage Cheat Sheet (the crash course) + Dockerfile example

Here are all the basic commands you need to know to work with Docker in the development environment:

  1. build an image named myAppImage from the current project folder (Dockerfile must be present):

    $ docker build . -t myAppImage
  2. run a container named myAppContainer from the image named myAppImage. In interactive mode (pressing Ctrl+C will stop it):

@cray0000
cray0000 / new_react_sharedb.js
Last active June 6, 2018 10:59
ROUGH Example on how to use new React Sharedb (not working)
import React from 'react'
import {model, subscribe} from 'react-sharedb'
model.set('_session.userId', model.id()) // Это приходит из сервака
/*
# Текущий юзер хранится в _session.userId
users {
firstName
lastName
import Quill from 'quill'
const Parchment = Quill.import('parchment')
const Block = Quill.import('blots/block')
const Container = Quill.import('blots/container')
class TableCell extends Block {
static formats (domNode) {
return domNode.tagName === this.tagName ? undefined : super.formats(domNode)