Skip to content

Instantly share code, notes, and snippets.

View chirag64's full-sized avatar

Chirag Bhatia chirag64

View GitHub Profile
# Watch a file changes in the current directory,
# Execute all tests when a file is changed or renamed
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = Get-Location
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($true)
-- MarI/O by SethBling
-- Feel free to use this code, but please do not redistribute it.
-- Intended for use with the BizHawk emulator and Super Mario World or Super Mario Bros. ROM.
-- For SMW, make sure you have a save state named "DP1.state" at the beginning of a level,
-- and put a copy in both the Lua folder and the root directory of BizHawk.
if gameinfo.getromname() == "Super Mario World (USA)" then
Filename = "DP1.state"
ButtonNames = {
"A",
@chirag64
chirag64 / NewsHighlight.js
Last active January 19, 2016 13:33
A quick and hacky script to fetch key sentences from a blog or news article. Basically fetches the sentences with most words in them.
// Get all sentences
var sentences = document.body.innerText.split(".");
// Remove all sentences with newline characters in them since they're likely tags or sidebar data
for (i=sentences.length - 1; i>-1; i--)
{
if (sentences[i].trim().indexOf("\n") !== -1)
{
sentences.splice(i,1);
}
Dim speaks, speech
If (Minute(Time()) = 0) Then
speaks = "It is now " & (((Hour(Time()) + 11) Mod 12) + 1) & " O' clock"
Else
speaks = "The time is now " & (((Hour(Time()) + 11) Mod 12) + 1) & " " & Minute(Time())
End If
Set speech = CreateObject("sapi.spvoice")
speech.Speak speaks
// Prints a Pascal Triangle of 'n' no. of lines
function PascalTriangle(n) {
var arr = [];
for (var i = 0; i < n; i++) {
// Create an array
arr[i] = [];
// Mark 1st and last element as 1
arr[i][0] = 1;
arr[i][i] = 1;
// 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 {
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;
@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

@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 / 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();})();