Skip to content

Instantly share code, notes, and snippets.

@sunny-mittal
sunny-mittal / recursively-rename-extension.sh
Created Oct 11, 2022 — forked from bzerangue/recursively-rename-extension.sh
Terminal Script: Recursively rename or change file extensions (this example, changing extension from .html to .php)
View recursively-rename-extension.sh
find . -name "*.html" | while read i; do mv "$i" "${i%.html}.php"; done
View machine.js
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,
View gist:2a0e11ca982d3391d4110f75a7933cb3
# 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
View challenge.js
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)
View challenge.js
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 Aug 20, 2017
'this' keyword explained
View this.js
// `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)
View keybase.md

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:

View Angular Vocabulary
## 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.