Skip to content

Instantly share code, notes, and snippets.

View nitinstp23's full-sized avatar
:octocat:

Nitin Misra nitinstp23

:octocat:
View GitHub Profile
@nitinstp23
nitinstp23 / truncate_rails_tables.rb
Created July 22, 2020 18:30 — forked from romanlehnert/truncate_rails_tables.rb
Truncate all tables in rails
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table|
next if table == 'schema_migrations'
case ActiveRecord::Base.connection.adapter_name.downcase.to_sym
when :mysql2 || :postgresql
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
when :sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table}")
end

Keybase proof

I hereby claim:

  • I am nitinstp23 on github.
  • I am nitinstp23 (https://keybase.io/nitinstp23) on keybase.
  • I have a public key ASCGw1ere7sj6g_7DvimKCxAcCoUdw-oiTCGh99Vn_hghQo

To claim this, I am signing this object:

@nitinstp23
nitinstp23 / es_talk_notes.md
Last active September 29, 2017 06:19
Elasticsearch Introduction

Elasticsearch Introduction

What is Elasticsearch?

  • It is a highly scalable, open-source, full-text search engine.
  • It allows you to store and search data quickly and in near real time.
  • It is built on top of Apache Lucene.
  • It is schemaless.
  • It stores data in the form of JSON documents.
  • It has REST Apis for storing and searching data.

Steps - Web (JavaScript)

  • Get AWS SDK for JavaScript and configure it from following steps from this AWS Guide.

  • Sample code to generate pre-signed URL:

    var s3 = new AWS.S3();
    var params = {Bucket: 'myBucket', Key: 'myKey'};
    s3.getSignedUrl('getObject', params, function (err, url) {
    

console.log("The URL is", url);

@nitinstp23
nitinstp23 / search_query_adidas.md
Last active July 2, 2016 15:48
Content Product Search API response
{
  "products":[{
    "id":"576d14e469702d4e35650100",
    "title":"Women's Adidas Originals Bf Tee",
    "slug":"womens-adidas-originals-bf-tee",
    "description":"The adidas Originals BF tee for women. Made with a super soft Cotton-Modal mix, it comes with a large Inked Trefoil graphic on the front with 3-Stripes across the chest.",
    "store_id":"575a668369702d0b353d0200",
    "store_name":"Adidas Originals, Brigade Road",
    "store_logo":"https://cloudfront.mobmerry.com/store/brand/575e345e69702d0b376c0200/thumb_ea7f2f8f253aa5417c2fd6a74a9e89bd.jpg",
@nitinstp23
nitinstp23 / branch_sdk_integration_error_info.md
Last active October 8, 2015 09:14
Branch SDK error info

If we extend our MobMerryApplication Class to BranchApp, then we get this error.

Build works properly if we extend our MobMerryApplication Class to Application (or MultiDexApplication).

Build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
puts "Loading all source files into memory :("
source = {}
Dir["app/**/**/*.*"].reject { |f| f =~ /assets/ }.each do |f|
source[ f ] = File.readlines( f )
end
puts "#{source.size} files loaded into memory"
require 'socket'
require 'base64'
Refresh = 1 # seconds to refresh image on server
screen_capture_command = 'screencapture -C -x tmp.png'
image = ''
latest = Time.now
server = TCPServer.new 3000
loop do