Skip to content

Instantly share code, notes, and snippets.

View mushfick's full-sized avatar
👌
saul goodman

Mohammed Khalid mushfick

👌
saul goodman
View GitHub Profile
@t-mart
t-mart / netrw quick reference.md
Last active October 17, 2025 21:15
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
// Bonfire: Seek and Destroy
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy?solution=function%20destroyer(arr)%20%7B%0A%20%20%2F%2F%20Remove%20all%20the%20values%0A%20%20var%20args%20%3D%20Array.prototype.slice.call(arguments).splice(1)%3B%0A%20%20%0A%20%20return%20arr.filter(function(val)%20%7B%0A%20%20%20%20return%20args.indexOf(val)%20%3D%3D%3D%20-1%3B%0A%20%20%7D)%3B%0A%7D%0A%0Adestroyer(%5B1%2C%202%2C%203%2C%201%2C%202%2C%203%5D%2C%202%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments).splice(1);
return arr.filter(function(val) {
// Bonfire: Falsy Bouncer
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer?solution=function%20bouncer(arr)%20%7B%0A%20%20%2F%2F%20Don%27t%20show%20a%20false%20ID%20to%20this%20bouncer.%0A%20%20return%20arr.filter(function(val)%20%7B%20%0A%20%20%20%20return%20(Boolean(val))%3B%0A%20%20%7D)%3B%0A%7D%0A%0Abouncer(%5B7%2C%20%22ate%22%2C%20%22%22%2C%20false%2C%209%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(val) {
return (Boolean(val));
});
// Bonfire: Mutations
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations?solution=function%20mutation(arr)%20%7B%0A%20%20arr%5B0%5D%20%3D%20arr%5B0%5D.toLowerCase()%3B%0A%20%20arr%5B1%5D%20%3D%20arr%5B1%5D.toLowerCase()%3B%0A%20%20%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%3D%20arr.length%3B%20i%2B%2B)%20%7B%0A%20%20%20if%20(arr%5B0%5D.indexOf(arr%5B1%5D%5Bi%5D)%20%3C%200)%0A%20%20%20%20return%20false%3B%0A%20%20%7D%0A%20%20return%20true%3B%0A%7D%0A%0A%0Amutation(%5B%22hello%22%2C%20%22hey%22%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
arr[0] = arr[0].toLowerCase();
arr[1] = arr[1].toLowerCase();
for(var i = 0; i <= arr.length; i++) {
// Bonfire: Mutations
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations?solution=function%20mutation(arr)%20%7B%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%3D%20arr.length%3B%20i%2B%2B)%20%7B%0A%20%20%20if%20(arr%5B0%5D.toLowerCase().indexOf(arr%5B1%5D%5Bi%5D.toLowerCase())%20%3C%200)%0A%20%20%20%20return%20false%3B%0A%20%20%7D%0A%20%20return%20true%3B%0A%7D%0A%0A%0Amutation(%5B%22hello%22%2C%20%22hey%22%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
for(var i = 0; i <= arr.length; i++) {
if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) < 0)
return false;
}
// Bonfire: Slasher Flick
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick?solution=function%20slasher(arr%2C%20howMany)%20%7B%0A%20%20%2F%2F%20it%20doesn%27t%20always%20pay%20to%20be%20first%0A%20%20return%20arr.slice(howMany%2C%20arr.length)%3B%0A%7D%0A%0Aslasher(%5B1%2C%202%2C%203%5D%2C%202)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
// it doesn't always pay to be first
return arr.slice(howMany, arr.length);
}
// Bonfire: Chunky Monkey
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey?solution=function%20chunk(arr%2C%20size)%20%7B%0A%20%20%2F%2F%20Break%20it%20up.%0A%20%20var%20newArray%20%3D%20%5B%5D%3B%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%20%2B%3D%20size)%20%7B%0A%20%20%20%20newArray.push(arr.slice(i%2C%20i%20%2B%20size))%3B%0A%20%20%7D%0A%20%20return%20newArray%3B%0A%7D%0A%0Achunk(%5B0%2C%201%2C%202%2C%203%2C%204%2C%205%5D%2C%202)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
// Break it up.
var newArray = [];
for(var i = 0; i < arr.length; i += size) {
newArray.push(arr.slice(i, i + size));
// Bonfire: Chunky Monkey
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey?solution=function%20chunk(arr%2C%20size)%20%7B%0A%20%20%2F%2F%20Break%20it%20up.%0A%20%20var%20count%20%3D%201%3B%0A%20%20var%20tempArray%20%3D%20%5B%5D%3B%0A%20%20var%20finalArray%20%3D%20%5B%5D%3B%0A%20%20%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20if(%20count%20%3C%3D%20size)%20%7B%0A%20%20%20%20%20%20tempArray.push(arr%5Bi%5D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20%7B%0A%20%20%20%20%20%20finalArray.push(tempArray)%3B%0A%20%20%20%20%20%20tempArray%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20count%20%3D%201%3B%0A%20%20%20%20%20%20tempArray.push(arr%5Bi%5D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20count%20%2B%3D%201%3B%0A%20%20%7D%0A%20%20finalArray.push(tempArray)%3B%0A%20%20return%20finalArray%3B%0A%7D%0A%0Achunk(%5B0%2C%201%2C%202%2C%203%2C%204%2C%205%5D%2C%202)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, s
// Bonfire: Truncate a string
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string?solution=function%20truncate(str%2C%20num)%20%7B%0A%20%20%2F%2F%20Clear%20out%20that%20junk%20in%20your%20trunk%0A%20%20if%20(num%20%3C%3D%203)%20%7B%0A%20%20%20%20return%20str.slice(0%2C%20num).concat(%27...%27)%3B%0A%20%20%7D%0A%20%20else%20%7B%0A%20%20%20%20return%20str.length%20%3E%20num%20%3F%20str.slice(0%2Cnum).replace(%2F.%7B3%7D%24%2F%2C%20%27...%27)%20%3A%20str%3B%0A%20%20%7D%0A%7D%0A%0Atruncate(%22A-tisket%20a-tasket%20A%20green%20and%20yellow%20basket%22%2C%2011)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
// Clear out that junk in your trunk
if (num <= 3) {
return str.slice(0, num).concat('...');
}
// Bonfire: Repeat a string repeat a string
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string?solution=function%20repeat(str%2C%20num)%20%7B%0A%20%20%2F%2F%20repeat%20after%20me%0A%20%20return%20num%20%3E%3D%200%20%3F%20new%20Array(num%2B1).join(str)%20%3A%20%22%22%3B%0A%7D%0A%0Arepeat(%22abc%22%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function repeat(str, num) {
// repeat after me
return num >= 0 ? new Array(num+1).join(str) : "";
}