Skip to content

Instantly share code, notes, and snippets.

@mtsmfm
mtsmfm / README.md
Last active August 10, 2021 15:22
Install eclipse che on docker desktop
$ kubectl apply -f https://gist.githubusercontent.com/mtsmfm/7d582a83f2c963273612d6dcd8f856c1/raw/6ebaff9d92a062d7cb886ff22bcad57c36f6f1cf/coredns-configmap.yaml
$ kubectl patch deployment coredns -n kube-system --patch "$(curl https://gist.githubusercontent.com/mtsmfm/7d582a83f2c963273612d6dcd8f856c1/raw/6ebaff9d92a062d7cb886ff22bcad57c36f6f1cf/coredns-deployment-patch.yaml)"
$ chectl server:deploy --platform=docker-desktop --domain che.127.0.0.1.nip.io
@mtsmfm
mtsmfm / README.md
Last active March 28, 2021 04:36
Ruby hangs when accessing array which is modified in instance_eval after Coverage.start https://bugs.ruby-lang.org/issues/13586

Step to reproduce

git clone https://gist.github.com/b8c57c198793b7e7b835ae3255f0037c.git
cd b8c57c198793b7e7b835ae3255f0037c
docker run --rm -v $PWD:/app -w /app ruby:2.4.1 ruby main.rb
docker run --rm -v $PWD:/app -w /app ruby:2.4.0 ruby main.rb
class LpGen
INFINITY = Float::INFINITY
module HasMembers
def set_coefficient(var, x)
members << Member.new(var, x)
end
def members
@members ||= []
@mtsmfm
mtsmfm / report.rb
Last active December 11, 2020 11:17
Report N+1 via New Relic API
require 'net/http'
require 'uri'
require 'json'
require 'time'
require 'csv'
class NrqlClient
def initialize(api_key:, account_id:)
@api_key = api_key
@account_id = account_id
@mtsmfm
mtsmfm / rewrite.go
Created November 24, 2020 01:48
rewrite.go
package main
import (
"go/ast"
"go/format"
"go/parser"
"go/token"
"io/ioutil"
"log"
"os"
$ DATABASE_URL=postgres://postgres:password@postgres/postgres?sslmode=disable go run utils/foo.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x68e9dc]
goroutine 1 [running]:
github.com/ericlagergren/decimal.(*Big).IsNaN(...)
/home/app/go/pkg/mod/github.com/ericlagergren/decimal@v0.0.0-20181231230500-73749d4874d5/big.go:853
github.com/volatiletech/sqlboiler/v4/types.decimalValue(0x0, 0x8fe300, 0x0, 0x0, 0x7fa1a03ebca0, 0x8a9601)
/home/app/go/pkg/mod/github.com/volatiletech/sqlboiler/v4@v4.2.0/types/decimal.go:140 +0x3c
github.com/volatiletech/sqlboiler/v4/types.Decimal.Value(0x0, 0xc0001a15f0, 0x40d1e5, 0x6c4760, 0x7007c0)
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'mongoid'
end
require 'yaml'
require 'tempfile'
class ArticleEntity < ArticleCommonEntity; end
def as_json
{id: @article.id, thumbnail_url: @article.thumbnail_url}
end
end
get "/articles" do
Article.all.map {|a| ArticleEntity.new(a) }.to_json
end
const postQuery = async <TData, TVariables>(query: string, variables: TVariables) => {
const token = await firebase.auth().currentUser!.getIdToken();
const resonse = await fetch('/graphql', {
method: 'POST',
body: JSON.stringify({ query, variables })
});
const json: { data: TData, errors: Array<any> | undefined } = await resonse.json();
const postQuery = async <TData, TVariables>(query: string, variables: TVariables) => {
const token = await firebase.auth().currentUser!.getIdToken();
const resonse = await fetch('/graphql', {
method: 'POST',
credentials: 'include',
headers: {
'content-type': 'application/json',
'authorization': `Bearer ${token}`,
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]')!.getAttribute('content')!