Skip to content

Instantly share code, notes, and snippets.

@sankalpk
sankalpk / config.js
Last active June 3, 2020 04:41
Update files for debugging
import runtimeEnv from '@mars/heroku-js-runtime-env'
const env = runtimeEnv()
const dotenv = require('dotenv')
dotenv.config()
export const {
REACT_APP_GRAPHQL_API_URL,
REACT_APP_BUGSNAG_KEY,
@sankalpk
sankalpk / create_user_mutation_spec.rb
Last active May 5, 2020 14:48
Create User Mutation Spec Example
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Mutations::CreateUser, 'create user mutation' do
before(:all) do
@basic_mutation = <<-GRAPHQL
mutation CreateUser($firstName: String!, $lastName: String!, $ssn: String, $dob: ISO8601Date!) {
createUser(firstName: $firstName, lastName: $lastName, ssn: $ssn, dob: $dob) {
user {
@sankalpk
sankalpk / commands.md
Last active August 21, 2019 20:50
Populate a Rails app w/ Elasticsearch

Clear and populate the database with fresh data:

rake db:populate

Clear the database:

rake db:clean
@sankalpk
sankalpk / readme.md
Last active May 25, 2019 05:08
Flask command not found with asdf

From the readme: https://github.com/danhper/asdf-python

If you use pip to install a module like ipython or flask that has a binaries. You will need to run asdf reshim python for the binary to be in your path.

asdf reshim python
@sankalpk
sankalpk / gist:f677c2617f7031ebed46dae8353b8cef
Created May 22, 2019 17:46
Run prettier fix on all files
prettier --write 'src/**/*.scss'
prettier --write 'src/**/*.css'
prettier --write 'src/**/*.js'
prettier --write 'src/**/*.jsx'
prettier --write 'src/**/*.html'
prettier --write 'public/**/*.html'
@sankalpk
sankalpk / gist:2d7d49ed073217402db8e94af1fa481a
Created May 13, 2019 18:06
Create Redshift Read Only User
CREATE GROUP ro_group;
CREATE USER <user_name> WITH password '<password>';
ALTER GROUP ro_group ADD USER <user_name>;
GRANT USAGE ON SCHEMA "public" TO GROUP ro_group;
@sankalpk
sankalpk / convert.rb
Created July 4, 2018 16:15
Convert form to form template in Cloverbook
email = "<INSERT_EMAIL_HERE>"
form_graph_id = "<INSERT_GRAPH_ID_HERE"
user = User.find_by_email
form = Form.find(GraphQL::Schema::UniqueWithinType.decode(form_graph_id)[1])
FormTemplate.create!(
user_id: user.id,
brand_id: user.primary_brand.id,
schema: form.schema,
@sankalpk
sankalpk / renew_square_access_token.rb
Created July 1, 2018 19:30
Update or Renew Square Access Token Using Ruby
require 'net/http'
def new_access_token(square_application_id, square_secret, square_access_token)
url = "https://connect.squareup.com/oauth2/clients/#{square_application_id}/access-token/renew"
headers = {
'Content-Type': 'application/json',
'Authorization': "Client #{square_secret}"
}
Verifying my Blockstack ID is secured with the address 1NMMG2avQ52vbDc1chhXTBPVCB1tA7hJiZ https://explorer.blockstack.org/address/1NMMG2avQ52vbDc1chhXTBPVCB1tA7hJiZ
@sankalpk
sankalpk / webpack-dev-server.js
Last active November 5, 2016 02:21
Webpack-rails with hot module reloading (HMR)
/* ./webpack-dev-server */
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const chalk = require('chalk');
const webpackConfig = require('./config/webpack.config.js');
const webpackDev = new WebpackDevServer(webpack(webpackConfig), {
contentBase: '/webpack/',
stats: {