Skip to content

Instantly share code, notes, and snippets.

View koyanloshe's full-sized avatar
👁️
Focusing

Alok Shenoy koyanloshe

👁️
Focusing
View GitHub Profile
@koyanloshe
koyanloshe / foundation.js
Last active April 17, 2020 08:32
Foundation equaliser #Javascript
/*
* This is a JavaScript Scratchpad.
*
* Enter some JavaScript, then Right Click or choose from the Execute Menu:
* 1. Run to evaluate the selected text (Cmd-R),
* 2. Inspect to bring up an Object Inspector on the result (Cmd-I), or,
* 3. Display to insert the result in a comment after the selection. (Cmd-L)
*/
(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==='object'&&typeof module==='object')
@koyanloshe
koyanloshe / commands.sh
Last active April 17, 2020 08:31
Static site generator #Javascript #Unix
// Step 1: Clone repository from GitHub
$ git clone https://github.com/ericalli/static-site-boilerplate
&& cd static-site-boilerplate && rm -rf .git && git init
// Step 2: Install dependencies
$ npm install
// Step 3: Run the development server
$ npm run start
// Step 4: Generate production-ready files
$ npm run build:dist
@koyanloshe
koyanloshe / .editorconfig
Last active April 17, 2020 08:31
EditorConfig #Unix
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
#################
# Common Settings
#################
# This file is the top-most EditorConfig file
root = true
@koyanloshe
koyanloshe / cloudSettings
Last active October 6, 2020 04:44
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-10-06T04:44:07.041Z","extensionVersion":"v3.4.3"}
@koyanloshe
koyanloshe / Art of naming variables
Last active June 15, 2019 08:18
Javascript Design Patterns #Javascript
// bad
const foo = y && z;
// good
const isPostEnabled = isPost && postDateValid;
/*The art of naming variables by Richard Tan[https://hackernoon.com/the-art-of-naming-variables-52f44de00aad]*/
@koyanloshe
koyanloshe / Promise using .then() after a .get()
Last active June 15, 2019 08:18
Async request example #Javascript
var request = require("request");
var userDetails;
function getData(url) {
// Setting URL and headers for request
var options = {
url: url,
headers: {
'User-Agent': 'request'
}
@koyanloshe
koyanloshe / Permissions
Created June 15, 2019 08:15
Linux Permissions #Linux
4 2 1
0 - - - no permissions
1 - - x only execute
2 - x - only write
3 - x x write and execute
4 x - - only read
5 x - x read and execute
6 x x - read and write
7 x x x read, write and execute
@koyanloshe
koyanloshe / gist:108a05d99f25fe2e79d966eb2afa9d9b
Last active April 17, 2020 08:27
Generate multiple requests #Javascript
const {promisify} = require('util')
const sleep = promisify(setTimeout)
const request = async(data) => {
let time = Math.random() * 1000
await sleep(time)
return {data, time}
}
var mimeTypes = {
'.html': 'text/html',
'.js': 'text/javascript',
'.css': 'text/css',
'.json': 'application/json',
'.png': 'image/png',
'.jpg': 'image/jpg',
'.gif': 'image/gif',
'.svg': 'image/svg+xml',
'.wav': 'audio/wav',
@koyanloshe
koyanloshe / css-layout-hack.js
Last active April 17, 2020 08:29 — forked from vcastroi/css-layout-hack.js
CSS in JS #Javascript
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}