Skip to content

Instantly share code, notes, and snippets.

View zerebral's full-sized avatar

Anand Mahajan zerebral

  • Zerebral IT Solutions Pvt Ltd
  • Pune
View GitHub Profile
@zerebral
zerebral / infiniteScrollWidget.dart
Created December 23, 2022 00:46
Infinite Scroll Widget + Algolia + FlutterFlow
// Automatic FlutterFlow imports
import '../../backend/backend.dart';
import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_util.dart';
import '../widgets/index.dart'; // Imports other custom widgets
import '../actions/index.dart'; // Imports custom actions
import '../../flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
@zerebral
zerebral / puppeteer-stealth-with-browserless.js
Last active September 1, 2023 22:35
Use puppeteer-extra-plugin-stealth with Browserless
const puppeteer_extra = require('puppeteer-extra');
puppeteer_extra.use(require('puppeteer-extra-plugin-anonymize-ua')());
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer_extra.use(StealthPlugin());
module.exports = async ({ context, browser }) => {
const { url } = context;
const ws_endpoint_url = browser.wsEndpoint();
const newBrowser = await puppeteer_extra.connect({
browserWSEndpoint: ws_endpoint_url
@zerebral
zerebral / page-load-test.js
Last active September 16, 2022 07:43
Puppeteer | Wait till all content is loaded in the browser
const waitTillHTMLRendered = async (page, timeout = 30000) => {
const checkDurationMsecs = 1000;
const maxChecks = timeout / checkDurationMsecs;
let lastHTMLSize = 0;
let checkCounts = 1;
let countStableSizeIterations = 0;
const minStableSizeIterations = 3;
while(checkCounts++ <= maxChecks){
let html = await page.content();
@zerebral
zerebral / move_jsar_gcloud.rb
Last active December 21, 2017 08:02
Watch a directory for new files and move those to Gcloud
require "ap"
path = ARGV[0]
bucket = ARGV[1]
while true do
files = Dir.glob("#{path}/*.jsar").select{|f| (Time.now - File.mtime(f)) > 60}
puts "-- Files to move - #{files.size}"
files.each{|file|
puts "-- -- Moving #{file}"
`gsutil -m mv #{file} #{bucket}`
@zerebral
zerebral / sheets_mc_functions.js
Last active November 15, 2017 07:43
Google Sheets Marketcheck Functions
function getDealerDomain(dealer_id) {
var url = 'http://marketcheck-prod.apigee.net/v1/dealer/'+ dealer_id + '?api_key=p3OCLOt1HQpxfp1zNVUVopAdWumsStPv';
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
Logger.log(response);
return JSON.parse(response).website_s
}
function getDomainInventoryCount(domain, inventory_type) {
var url = 'http://marketcheck-prod.apigee.net/v1/search?api_key=p3OCLOt1HQpxfp1zNVUVopAdWumsStPv&source=' + domain + '&car_type=' + inventory_type;
@zerebral
zerebral / Storm Error filter commands
Last active September 16, 2017 07:19
Autobot Storm Error Filter commands
export TOPOLOGY_ID=mc_vdp_crawler-1-1505395275
Grep Error from Autobot Logs -
ansible -i hosts_sample supervisor -a 'bash -lc "grep Error /home/anand/apache-storm-1.1.0/logs/workers-artifacts/ab-parser-logs/*"'
Proxy fetch success counts -
ansible -i hosts_sample supervisor -a "bash -lc \"grep 'Proxy fetcher tuple success' ~/storm-1.1.0_6/storm/apache-storm-1.1.1/logs/workers-artifacts/$TOPOLOGY_ID/670*/*.log* | wc -l\""
Proxy fetch error counts -
ansible -i hosts_sample supervisor -a 'bash -lc "grep XXX ~/storm-1.1.0_6/storm/apache-storm-1.1.1/logs/workers-artifacts/$TOPOLOGY_ID/670*/*.log* | wc -l"'
@zerebral
zerebral / Storm & Zookeeper Cleanup & restart
Last active February 22, 2018 12:42
Clean up Storm state and restart the cluster
To clean up Zk and Storm local stores and restart cluster -
On red01
cd /home/anand/projects/ansible-storm
ansible-playbook -i hosts_sample roles/stop_storm.yaml
ansible -i hosts_sample supervisor -a 'bash -lc "killall ruby"'
Check if no ruby processes running on the supervisors - repeat killall till you see no processes
ansible -i hosts_sample supervisor -a 'bash -lc "ps -ef | grep ruby"'
@zerebral
zerebral / vin_scan.rb
Created August 29, 2017 14:01
QnD script to scan VINs in all files in a directory recursively
letter_value = {'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4,
'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8,
'J' => 1, 'K' => 2, 'L' => 3, 'M' => 4,
'N' => 5, 'P' => 7, 'R' => 9, 'S' => 2,
'T' => 3, 'U' => 4, 'V' => 5, 'W' => 6,
'X' => 7, 'Y' => 8, 'Z' => 9, '1' => 1,
'2' => 2, '3' => 3, '4' => 4, '5' => 5,
'6' => 6, '7' => 7, '8' => 8, '9' => 9, '0' => 0,
'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4,
'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8,
@zerebral
zerebral / solr_commands
Last active May 1, 2018 03:06
Useful Solr Commands
Pre-requisites -
1. You'd need Ruby installed on the host(rvm.io)
2. Set the solr host env variable
export SOLR_HOST=10.68.77.13:8983
3. Set the collection name env var
export SOLR_COLLECTION=<your collection name>
DROP the Solr Collection
curl "http://$SOLR_HOST/solr/admin/collections?action=DELETE&name=$SOLR_COLLECTION"
@zerebral
zerebral / gist:c9f223cd3426f1042ead35f211142594
Created December 14, 2016 17:23
Ruby process invoked from a lambda cannot find the gem
bundler-1.9.9/lib/bundler.rb:122:in `setup'
2016-12-14T13:57:09.833Z 31533325-c205-11e6-98eb-f1a7b4768b8e from /var/task/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/setup.rb:18:in `<top (required)>'
from /var/task/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /var/task/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /var/task/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
2016-12-14T13:57:09.915Z 31533325-c205-11e6-98eb-f1a7b4768b8e {"errorMessage":"Command failed: /bin/sh -c ./hello
/var/task/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find i18n-0.7.0 in any of the sources (Bundler::GemNotFound)