Skip to content

Instantly share code, notes, and snippets.

View hrishimittal's full-sized avatar

Hrishi Mittal hrishimittal

View GitHub Profile
@hrishimittal
hrishimittal / resources.md
Last active August 5, 2024 09:38 — forked from andycandrea/resources.md
A list of resources for learning Rails and relevant technologies

A list of resources that aspiring Rails developers can use to learn Rails and other relevant technologies.

Ruby

  • Codecademy
    • One of the more well-known sites to offer interactive programming tutorials, Codecademy is probably best utilized by those who are pretty new to programming, though the Ruby tutorial is good for teaching Ruby syntax and eventually gets into some less trivial material.
  • Try Ruby
    • Pretty similar to Codecademy. Once again, it's beginner-friendly, though, as someone who knew about object-oriented programming beforehand, I found it somewhat annoying to use, as there's no page with links to the individual exercises (at least from what I could tell).
  • RubyMonk
  • As with the previous two resources, RubyMonk offers interactive tutorials. However, it has several different courses on various programming topics and for different experience levels, which
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) %>