Skip to content

Instantly share code, notes, and snippets.

View hrishimittal's full-sized avatar

Hrishi Mittal hrishimittal

View GitHub Profile
def solve(url)
require 'net/http'
require 'json'
uri = URI(url)
response = JSON.parse(Net::HTTP.get(uri))
puts response
solve(response["follow"].gsub('challenge', 'challenge.json')) if response["message"] == "This is not the end"
end
solve("https://www.letsrevolutionizetesting.com/challenge.json")
div.css-1dbjc4n.r-1dgieki.r-1efd50x.r-5kkj8d.r-13awgt0.r-18u37iz.r-tzz3ar.r-s1qlax.r-1yzf0co {
display: none;
}
div.css-1dbjc4n.r-13awgt0.r-18u37iz.r-1w6e6rj {
display: none;
}
span.css-901oao.css-16my406.r-poiln3.r-n6v787.r-1cwl3u0.r-1k6nrdp.r-1e081e0.r-qvutc0 {
display: none;
@hrishimittal
hrishimittal / add_to_mailchimp_group.rb
Created April 6, 2021 17:51
Add email to Mailchimp group via API
def add_to_mailchimp_group(email)
gibbon = Gibbon::Request.new
gibbon.lists('some_list_id')
.members(Digest::MD5.hexdigest(email.downcase).downcase)
.upsert(body: {
email_address: email,
status: "subscribed",
interests: {'some_group_id' => true},
merge_fields: {"MERGE1" => 'merge_field_value'}
})
@hrishimittal
hrishimittal / rnmap.js
Created October 13, 2018 11:57
react-native-webview-leaflet on iOS
import React from 'react';
import { StyleSheet } from 'react-native';
import WebViewLeaflet from 'react-native-webview-leaflet';
onLoad = (event) => {
const mapLayers = [
{
name: 'OpenStreetMap',
checked: 'true',
type: 'TileLayer',
@hrishimittal
hrishimittal / gist:4754b7d5a5c5ad68c673ba5562573a73
Created July 23, 2018 11:22 — forked from jacobvosmaer/gist:3187346
Open all files with git merge conflicts in Vim

Open all files with git merge conflicts in MacVim

git diff --name-only | uniq | xargs mvim

When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.

Once you're in Vim, you can then switch between the files with :n and :prev, or another favourite: :w | n (save current file and open the next command line-supplied file).

UPDATE: see below for a version that works with real terminal commands.

#Put this in application_controller.rb to trace all redirects
def redirect_to(options = {}, response_status = {})
puts("Redirected by #{caller(1).first rescue "unknown"}")
super(options, response_status)
end
#Put this in application_controller.rb to trace all redirects

[title] How to use React with a Rails 5 API app - A hands-on tutorial

[intro]

  • React and Rails make a great combination
  • In this hands-on tutorial, I'll show you how to build a complete React app that works with a Rails 5 API
  • You need to be comfortable with Rails but don't need to be a JavaScript or React expert
  • What we're going to build - an Idea board!
  • Outline of the steps we'll take to build this app
@hrishimittal
hrishimittal / FormErrors.js
Last active March 12, 2017 17:53
react form validation
import React from 'react';
export const FormErrors = ({formErrors}) =>
<div className='formErrors'>
{Object.keys(formErrors).map((fieldName, i) => {
if(formErrors[fieldName].length > 0){
return (
<p key={i}>{fieldName} {formErrors[fieldName]}</p>
)
} else {
@hrishimittal
hrishimittal / index.html.erb
Last active February 26, 2017 22:19
shopping list items
<%= react_component('Lists', lists: @lists) %>
@hrishimittal
hrishimittal / importxml.md
Last active February 9, 2017 10:14
ImportXml function for scraping web data into Google Sheets

#ImportXml function for scraping web data into Google Sheets

Note: All URLs must include the protocol - http:// or https://

Page Title

=IMPORTXML(URL, "//title")

Page Description