I hereby claim:
- I am hrishimittal on github.
- I am hrishio (https://keybase.io/hrishio) on keybase.
- I have a public key whose fingerprint is 8A14 B5B8 2EFD B349 E1F7 F38A C84E 006F 6C18 3EED
To claim this, I am signing this object:
#Given an array, get counts of occurences for each element | |
#H/T http://jerodsanto.net/2013/10/ruby-quick-tip-easily-count-occurrences-of-array-elements/ | |
def count_array_element_occurences(arr) | |
arr.each_with_object(Hash.new(0)) { |word,counts| counts[word] += 1 } | |
end | |
#Given a hash, convert it to an HTML table | |
def hash_to_table(h) | |
t = "<table><thead>" | |
if h.present? |
I hereby claim:
To claim this, I am signing this object:
#Dump database | |
pg_dump -Fc -f filename.pgdump database_name | |
#Restore db from dump | |
dropdb database_name && createdb database_name | |
pg_restore -n public -x -d database_name -j 2 -Fc filename.pgdump > /dev/null | |
psql: | |
#create role |
#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
<%= react_component('Lists', lists: @lists) %> | |
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 { |
[title] How to use React with a Rails 5 API app - A hands-on tutorial
[intro]
#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 |
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.
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', |