Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Have you tried turning it off and on again?

Viktor Fonic vfonic

💭
Have you tried turning it off and on again?
  • Ada Apps
View GitHub Profile
View sign_up.rb
def save
ActiveRecord::Base.transaction do
user = User.save(username: username) # user doesn't have to be instance var @user
add_errors(user.errors) unless user.persisted?
tweet = Tweet.save(body: first_tweet, user_id: user.id)
add_errors(tweet.errors) unless tweet.persisted?
user.persisted? && tweet.persisted?
end
end
View lazyimages.jsx
import React from 'react';
import moment from 'moment';
import LazyLoad from 'react-lazyload';
import './albums.css'
export default (props)=>{
function formatDate(date, format){
return moment(date).format(format);
@vfonic
vfonic / uninstall_rails_version.sh
Created Jul 13, 2017
Script for uninstalling all rails gem dependencies for the given rails version
View uninstall_rails_version.sh
#!/bin/bash -e
gem uninstall railties rails actionmailer actioncable actionpack actionview activerecord activejob activemodel activesupport -v $1
View bundle env.md

Environment

Bundler   1.15.0
Rubygems  2.6.10
Ruby      2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
GEM_HOME  /Users/viktorfonic/.rvm/gems/ruby-2.4.0
GEM_PATH  /Users/viktorfonic/.rvm/gems/ruby-2.4.0:/Users/viktorfonic/.rvm/gems/ruby-2.4.0@global
RVM       1.29.1 (latest)
Git       2.13.0
View externalize.sh
#!/bin/bash -e
function externalize_git {
if [ ! -d "$git_repos_repo_full_path" ]; then
mkdir -p "$git_repos_repo_full_path"
mv .git "${git_repos_repo_full_path}"/.git
git --git-dir="${git_repos_repo_full_path}/.git" --work-tree=. init && echo "gitdir: ${git_repos_repo_full_path}/.git" > .git
else
echo "Directory $git_repos_repo_full_path already exists!"
fi
You can’t perform that action at this time.