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 / carrierwave-base64.md
Created February 24, 2017 14:56 — forked from shrikanthkr/carrierwave-base64.md
Saving base64 string with Carrierwave

In the controller action

image_file = change_img_params(params[:avatar]) #params[:avatar] - base64 string

def change_img_params(img)
begin
  Base64.decode64(img) #To check if thats a base64 string
  if img
    img = file_decode(img.split(',')[1],"some file name") #getting only the string leaving out the data/<format>

end

@IlkhamGaysin
IlkhamGaysin / SCSS.md
Created February 27, 2017 14:58 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

To count objects in current thread you can use this approach.

class OtherKlass
end

OtherKlass.new
OtherKlass.new

ObjectSpace.each_object(OtherKlass){} # =&gt; 2
class ContentSuggestionEnqueuer
  def self.enqueue
    User.where(subscribed: true).pluck(:id).each do |user_id|
      ContentSuggestionWorker.perform_async(user_id)
    end
  end
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,
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
du -h --max-depth=1 | sort -hr
@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
@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 / 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