Skip to content

Instantly share code, notes, and snippets.

@mantrala
mantrala / gist:22f368a54f73cac3c4dc56bce6d674e2
Created November 22, 2020 05:31 — forked from n00neimp0rtant/gist:9515611
simple squash without rebase
## 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
The crmID is predominantly used to fetch a person in `people_service` by looking by via the crmID.
compass.com/contacts/subscribers/newperson/handlers/process_invite.go:169 uses crmID to fetch a person. This call can be
avoided if `contactually.UserInvite` can return the users `external_id` from c10y.
src/go/compass.com/people/server/people.go:359 #GetPersonByCRMID method should be deprecated and a new a similar
method which queries based on personID should be used.
The existing `get /person` call could be used, but that endpoint seems to be doing a lot of other work.
Bulk of the usage of crmID happens in the `src/go/compass.com/people/api/agent.go` file which is used to create/update
@mantrala
mantrala / prof.rb
Created March 16, 2018 15:40 — forked from teamon/prof.rb
Profile rails controller with ruby-prof
# gem "ruby-prof"
around_filter :profiler
def profiler(&block)
data = RubyProf::Profile.profile(&block)
filepath = Rails.root.join("tmp", "profiler.html")
File.open(filepath, "w") do |f|
RubyProf::CallStackPrinter.new(data).print(f)
def level_up(arr, init=[])
arr.each do |elm|
if elm.class == Array
level_up(elm, init)
else
init << elm
end
end
init
@mantrala
mantrala / migration.rb
Last active September 2, 2015 00:54 — forked from serek/migration.rb
Migration from attachment_fu to paperclip.
class ConvertImagesToPaperclip < ActiveRecord::Migration
include PaperclipMigrations
def self.up
# Paperclip
add_column :images, :data_file_name, :string
add_column :images, :data_content_type, :string
add_column :images, :data_file_size, :integer
add_column :images, :data_updated_at, :datetime
@mantrala
mantrala / AWS S3
Last active September 4, 2015 19:42
# creating a bucket
s3 = Aws::S3:Client.new(region: 'us-west-1')
s3.create_bucket(bucket: 'bucket-name')
#bucket can also be created as
s3 = Aws::S3::Resource.new
s3.create_bucket(bucket: 'xxxx')
#check if a bucket exists?
s3 = Aws::S3::Resource.new
# creating a bucket
s3 = Aws::S3:Client.new(region: 'us-west-1')
s3.create_bucket(bucket: 'bucket-name')
#bucket can also be created as
s3 = Aws::S3::Resource.new
s3.create_bucket(bucket: 'xxxx')
#check if a bucket exists?
s3 = Aws::S3::Resource.new
s3.bucket('lp-internal-sarath-test').exists?
@mantrala
mantrala / gist:ea9fe4166846981da5c4
Created February 24, 2015 20:49
Upgrade Postgres from 9.3 to 9.4 on Ubuntu 12.04
Upgrade Postgres 9.4
Ubuntu 12.04 (precise) does not have postgresql-9.4 distribution. We will need to use PostgreSQL APT repository to update.
More info here: http://www.postgresql.org/download/linux/ubuntu/
sudo apt-get install postgresql-9.4
sudo apt-get install postgresql-contrib-9.4 (for hstore extensions)
pg_lsclusters show now list two existing clusters 9.3 and 9.4
Version Cluster Port Status Owner Data directory
9.3 main 5433 down postgres /var/lib/postgresql/9.3/main

Record a screencast with QuickTime Player

  1. Connect an iOS defice with a cable
  2. In QuickTime Player: Option-Cmd-N (New Movie Recording) -> Select your device from the recording menu:

http://cl.ly/image/1w0y3Y0H2g2X/record.png

Install gifify