Skip to content

Instantly share code, notes, and snippets.

View IlkhamGaysin's full-sized avatar
🏠
Working from home

Ilkham Gaysin IlkhamGaysin

🏠
Working from home
View GitHub Profile
@IlkhamGaysin
IlkhamGaysin / homebrew-install-older-version.md
Created April 18, 2023 14:49
Homebrew: Install an older version of a formula

Homebrew: Install an older version of a formula

kubernetes-cli (v1.10.3) taken as example

  1. Downgrade Homebrew to the commit which upgrades the formula to the specific version that we want
$ cd "$(brew --repo homebrew/core)"
$ git log Formula/kubernetes-cli.rb

...
@IlkhamGaysin
IlkhamGaysin / concatenate_all_tsx-gz_files.md
Last active June 4, 2021 12:37
Concatenate all tsv.gz files info one

Problem

Usually logs files are stored in butches with tsv.gz file extention. Often we need to search trough these logs as they are the one file.

Solution

we can unzip and concatenate the files into one file and grep over it.

  gunzip -c *.gz > alllogs

Options:

  • е — encrypt archive contents with password;
  • j — drop the path to the root folder i.e. Archive only its contents without regard to the folder itself;
  • r — recursively add folder contents.
 zip -ejr [path_of_new_file_with_name] [path_to_file_to_zip]

Lazy

a = [1,2,3,4,2,5].lazy.map { |x| x * 10 }.select { |x| x > 30 } #=> no evaluation and creations of arrays

a.to_a #=> [40, 50], evaluation performed - no intermediate arrays generated.

Eager

@IlkhamGaysin
IlkhamGaysin / import_and_export_in_postgres.md
Last active February 19, 2018 09:51
Import and Export *.sql file to local database

Import

psql -U postgres -h 0.0.0.0 -p 5434 -W nywt_development  < ~/Documents/dumps/dump.sql

Export

psql -U postgres -h 0.0.0.0 -p 5434 -W nywt_development  > ~/Desktop/dumps/gzip dump.sql.gz
@IlkhamGaysin
IlkhamGaysin / banchmarking_memory.md
Last active August 10, 2017 14:44
Simple benchmarking memory usage and spend time

Simple benchmarking memory usage and spend time

Usage

print_metrics do
  #...your code...#
end

# Or by single method
@IlkhamGaysin
IlkhamGaysin / test_sample.md
Created April 2, 2017 10:55
Introducing to testing of mine
class NumberGenerator
  VERSION = "0.1.0".freeze

  attr_reader :message_receiver

  def initialize(message_receiver)
    @message_receiver = message_receiver
  end
du -h --max-depth=1 | sort -hr
require 'socket'

server = TCPServer.new("127.0.0.1", 2000)
loop do
  Thread.start(server.accept) do |client|
    client.puts "Hello !"
    client.puts "Time is #{Time.now}"
    client.close
 end
import React, { Component, PropTypes } from 'react';
import { ListGroup } from 'react-bootstrap';
import Todo from 'components/todo';

export default class TodoList extends Component {
  static propTypes = {
    todos: PropTypes.arrayOf(
      PropTypes.shape({
 id: PropTypes.number,