Skip to content

Instantly share code, notes, and snippets.

def update_by_ids(ids:, model: self, condition: nil, update_values:, chunk: 100)
return if ids.empty?
scp = model.all
scp = scp.where(condition) if condition
sorted_ids = ids.sort
sorted_ids.each_slice(chunk) do |ids_group|
scp.where('id >= ? AND id <= ?', ids_group.min, ids_group.max).where(id: ids_group)
scp.update_all(update_values)
@ivanthecrazy
ivanthecrazy / fix_git_ps1.sh
Created May 27, 2021 09:00 — forked from tuksik/fix_git_ps1.sh
Fix -bash: __git_ps1: command not found
#http://stackoverflow.com/questions/12870928/mac-bash-git-ps1-command-not-found
curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
echo 'source ~/.git-prompt.sh' >> ~/.bashrc
## within current branch, squashes all commits that are ahead of master down into one
## useful if you merged with upstream in the middle of your commits (rebase could get very ugly if this is the case)
## commit any working changes on branch "mybranchname", then...
git checkout master
git checkout -b mybranchname_temp
git merge --squash mybranchname
git commit -am "Message describing all squashed commits"
git branch -m mybranchname mybranchname_unsquashed
git branch -m mybranchname
@ivanthecrazy
ivanthecrazy / Android Home
Created October 26, 2017 10:07 — forked from ericaroy/Android Home
Setting Android Home on Mac
Note for me to remember how to set Android Home on Mac
Open Terminal and type in..
nano ~/.bash_profile
Add the below paths
The path should be where your android installation is located
export ANDROID_HOME=/Users/username/Library/Android/sdk
export export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Save file and type in terminal...
source ~/.bash_profile
@ivanthecrazy
ivanthecrazy / android_instructions.md
Created June 20, 2017 15:15 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@ivanthecrazy
ivanthecrazy / application.rb
Created January 27, 2017 12:44 — forked from basti/application.rb
Local Rails 4 assets precompilation using Capistrano 3 and rsync
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@ivanthecrazy
ivanthecrazy / demo.md
Created December 26, 2016 07:18 — forked from danharper/demo.md
Open native Maps apps on iOS and Android in Cordova
iOS (with pin, iOS will lookup address too and show that as label)
maps://?q=LAT,LNG
Android, no pin (just open at location)
geo:LAT,LNG
@ivanthecrazy
ivanthecrazy / gist:4169e19d5407c160e4966f8e487f961b
Created July 23, 2016 08:20 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path
@ivanthecrazy
ivanthecrazy / node-and-npm-in-30-seconds.sh
Created June 7, 2016 14:13 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@ivanthecrazy
ivanthecrazy / routes.rb
Created January 9, 2016 09:00 — forked from kryzhovnik/routes.rb
Интеграция Яндекс.Кассы с Rails
# config/routes.rb
YandexKassaIntegration::Application.routes.draw do
# ...
scope '/yandex_kassa' do
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do
post :check
post :aviso
get :success
get :fail