Skip to content

Instantly share code, notes, and snippets.

View ChandanChainani's full-sized avatar

ChandanChainani

View GitHub Profile
@ChandanChainani
ChandanChainani / _setup.txt
Created September 13, 2022 18:34 — forked from afeld/_setup.txt
Seven Languages in Seven Months: Ruby presentation
git clone git://gist.github.com/3944262.git seven_langs_ruby
cd seven_langs_ruby
gem install gli -v 1.6.0
gem install showoff
showoff serve
open "http://localhost:9090"
@ChandanChainani
ChandanChainani / domains.sh
Created September 13, 2022 18:35 — forked from afeld/domains.sh
get all domains (record sets) from all zones in an account in AWS Route53
#!/bin/bash
set -eo pipefail
aws route53 list-hosted-zones --query 'HostedZones[].Id' | \
jq -r '.[]' | sed 's/\/hostedzone\///' \
| \
xargs -I zone_id \
aws route53 list-resource-record-sets \
--hosted-zone-id zone_id \
@ChandanChainani
ChandanChainani / erlang-websocket-sample.md
Created November 3, 2022 07:15 — forked from jcfrank/erlang-websocket-sample.md
A simple erlang cowboy websocket app

Simple Cowboy websocket app

Cowboy is such a simple web framework.
This is a sample websocket app.

new project

Use erlang.mk. Not that you have to, but it'd make things a bit easier.
First, create a folder for project, ex. myproject.
$ cd myproject/

@ChandanChainani
ChandanChainani / azure-key-credentials.py
Created November 3, 2022 07:16 — forked from jcfrank/azure-key-credentials.py
Python script to print out information to configure an Azure app's keyCredentials entry.
#!/usr/bin/env python3
import os
import sys
from base64 import b64encode
from uuid import uuid4
try:
from cryptography import x509
from cryptography.hazmat.backends import default_backend
@ChandanChainani
ChandanChainani / private_fork.md
Created November 20, 2022 06:47 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@ChandanChainani
ChandanChainani / dsu.js
Created February 19, 2023 16:42 — forked from KSoto/dsu.js
Disjoint Set Union (DSU) with Union Find in Javascript
// https://www.youtube.com/watch?v=wU6udHRIkcc
/*
Disjoint Set Union (“DSU”) is the Data Structure: disjoint-set data structure
is a data structure that keeps track of a set of elements partitioned into a
number of disjoint (non-overlapping) subsets.
Union Find is the Algorithm: A union-find algorithm is an algorithm that can
be used to detect cycles in an undirected graph & performs two useful operations
on such a data structure:
@ChandanChainani
ChandanChainani / rspec_rails_cheetsheet.rb
Created February 20, 2023 17:24 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@ChandanChainani
ChandanChainani / string-conversion.rs
Created February 24, 2023 07:31 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
//Authorization popup window code
function ShowAuthWindow(options)
{
console.log('ee');
options.windowName = options.windowName || 'ConnectWithOAuth'; // should not include space for IE
options.windowOptions = options.windowOptions || 'location=0,status=0,width=800,height=400';
options.callback = options.callback || function(){ window.location.reload(); };
var that = this;
console.log(options.path);
that._oauthWindow = window.open(options.path, options.windowName, options.windowOptions);

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger