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 / 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

@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 / gist:de0b4182e025878819ce9b336842943c
Created February 6, 2017 12:43 — forked from atcuno/gist:3425484ac5cce5298932
HowTo: Privacy & Security Conscious Browsing

The purpose of this document is to make recommendations on how to browse in a privacy and security conscious manner. This information is compiled from a number of sources, which are referenced throughout the document, as well as my own experiences with the described technologies.

I welcome contributions and comments on the information contained. Please see the How to Contribute section for information on contributing your own knowledge.

Table of Contents

Transactions

As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.

Basics

All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.

Example

@IlkhamGaysin
IlkhamGaysin / gist:85b179e09fba41f7b40954376daa99f1
Created June 4, 2016 13:31 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do