Skip to content

Instantly share code, notes, and snippets.

@sunny-mittal
sunny-mittal / recursively-rename-extension.sh
Created October 11, 2022 21:26 — forked from bzerangue/recursively-rename-extension.sh
Terminal Script: Recursively rename or change file extensions (this example, changing extension from .html to .php)
find . -name "*.html" | while read i; do mv "$i" "${i%.html}.php"; done
@sunny-mittal
sunny-mittal / machine.js
Last active April 15, 2021 17:32
Generated by XState Viz: https://xstate.js.org/viz
const randomResolution = () => new Promise(resolve => {
setTimeout(() => {
Math.random() < 0.5 ? resolve(true) : resolve(false);
}, 1000);
});
const checkForApplication = randomResolution;
const submitApplication = randomResolution;
const DEFAULT_CONTEXT = {
applicantContact: false,
authenticated: false,
# CRUNCH - created from Steve Eley's cat waxing.
# Initially hacked from the Dallas theme. Thanks, Dallas Reedy.
#
# This theme assumes you do most of your oh-my-zsh'ed "colorful" work at a single machine,
# and eschews the standard space-consuming user and hostname info. Instead, only the
# things that vary in my own workflow are shown:
#
# * The time (not the date)
# * The RVM version and gemset (omitting the 'ruby' name if it's MRI)
# * The current directory
function canIMake(list, target) {
if (target === 1) return true
if (target === 0) return false
if (list.length === 0) return false
if (list.length === 1) {
if (list[0] % target !== 0) return false
return true
}
const modded = list.map(val => val % target)
function canIMake(list, target) {
if (target === 1) return true
if (target === 0) return false
if (list.length === 0) return false
if (list.length === 1) {
if (list[0] % target !== 0) return false
return true
}
const modded = list.map(val => val % target)
@sunny-mittal
sunny-mittal / this.js
Created August 20, 2017 21:20
'this' keyword explained
// `this` is possibly one of the most confusing parts of JavaScript and one that can be modified the most. ES6 also provides ways to handle it, but I'll skip those for now
// So what is "this?" this represents the current execution context and can be very important for debugging and understanding behavior. To follow along, just go to about:blank in chrome and open the dev tools. It'll give you a clean slate to work with:
function testThis() {
console.log(this)
}
testThis() // This will log out the "window" object, which is the topmost context in a browser, which should make sense. For the most part, any function that doesn't have a `.` preceding it is going to have "window" as the `this` context (I'll explain how to change it later on)

Keybase proof

I hereby claim:

  • I am sunny-mittal on github.
  • I am sunnymittal (https://keybase.io/sunnymittal) on keybase.
  • I have a public key whose fingerprint is 6DEE C372 204F 43DF 8B63 CC35 0546 DE50 2F9A DEE0

To claim this, I am signing this object:

## Angular Vocabulary
### Scope
The execution context for expressions
### Controller
A JavaScript constructor function used to modify $scope.
### Data Binding
A two-way relationship between model and view that are automatically synchronized.