Skip to content

Instantly share code, notes, and snippets.

View chirag64's full-sized avatar

Chirag Bhatia chirag64

View GitHub Profile
@chirag64
chirag64 / Rust Frequent Operations.md
Last active January 20, 2023 14:06
Kind of like a cheat sheet

How to guide for frequent operations in Rust

For loop - vector

for i in my_vec {
    println!("Current item: {}", i);
}
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
export default (async function showResults(values) {
await sleep(500); // simulate server latency
window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`);
});

Keybase proof

I hereby claim:

  • I am chirag64 on github.
  • I am chirag64 (https://keybase.io/chirag64) on keybase.
  • I have a public key ASDseZqOWzHkMOCv3fQ9eN66LeyevtgcnKjaFdDVhnfAIwo

To claim this, I am signing this object:

@chirag64
chirag64 / Mimic SQL select * statement in SOQL using Apex
Created April 21, 2018 19:27 — forked from johncasimiro/Mimic SQL select * statement in SOQL using Apex
A code snippet that mimics the popular Select * SQL syntax in force.com's Apex language.
/*
* @description: A code snippet that mimics the popular Select * SQL syntax in force.com's Apex language.
*/
// Initialize setup variables
String objectName = 'Contact'; // modify as needed
String query = 'SELECT';
Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
// Grab the fields from the describe method and append them to the queryString one by one.
@chirag64
chirag64 / SwiggyRandomizer-min.js
Last active January 1, 2018 11:31
Load the webpage with all restaurants that deliver at your desired address (like https://www.swiggy.com/mumbai/restaurants) with all restaurants loaded on the web page (keep scrolling down till it loads all) and then run the script. For 1 time use, copy-paste the code of unminified file in your browser console. For regular use, create a bookmark…
javascript:(function(){var r=$(".restaurant-container:not(:has(.closed))");r.css("border","");var o=Math.floor(Math.random()*r.length);r[o].style.border="3px solid red";r[o].scrollIntoView();})();
@chirag64
chirag64 / README.md
Created April 8, 2017 12:27 — forked from micjamking/README.md
[Git] Git-to-Github Workflow

Git Workflow

Below is our current practice for using Git (the technology) & Github (the repository) when collaborating on projects. This process assumes that you already have Git installed & configured, and there is an existing project repository on Github with a "development" branch already setup.

If you do not have Git installed, follow these instructions.

This process also assumes that you are using the command line, however most of these tasks can be performed with a desktop client like Github for Mac or Tower.

Process

Getting Started

1.) Open terminal and locate the project directory you wish to use.

@chirag64
chirag64 / GitHub-Forking.md
Created April 8, 2017 12:27 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

function GnomeSort(arr) {
for (var i = 0; i < (arr.length - 1);) {
// Compare next 2 elements, if they are in correct order, go ahead, else swap them and go back one step
if (arr[i] <= arr[i + 1]) {
i++;
} else {
var temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
// Recursive function to flatten out a multi-dimensional array
function FlattenArray(arr) {
var newArr = [];
for (var i = 0; i < arr.length; i++) {
// Go through each elements of array, if element is array, call this function with it as parameter and then concatenate
// with the new array, else just add the element to the new array, then return the new array in the end
if (Array.isArray(arr[i])) {
newArr = newArr.concat(FlattenArray(arr[i]));
}
else {