Skip to content

Instantly share code, notes, and snippets.

View VinayakHegde's full-sized avatar

Vinnie VinayakHegde

  • Viva Technology Consultancy Ltd
  • london
View GitHub Profile
Aspect JavaScript Python
Primary Numeric Data Type number int and float
String Data Type string str
Boolean Data Type boolean bool
Array/List Data Type array list
Object/Dictionary Data Type object dict
Set Data Type Set set
Tuple Data Type Not directly supported tuple
Function Declaration function functionName() { /* code */ } def function_name():
Arrow Functions (Lambda) (param) => expression lambda param: expression
@VinayakHegde
VinayakHegde / collections.csv
Last active January 8, 2024 23:01
Collections Python vs Javascript
Collection Javascript Python
Arrays let array = [1, 2, 3, 4, 5]; array_is_list_in_python = [1, 2, 3, 4, 5]
Objects let obj = { name: 'John', age: 30} obj_is_dict_in_python = { name: 'John', age: 30}
Sets let set = new Set([1, 2, 3, 4, 5]) my_set = {1, 2, 3, 4, 5}
Maps let map = new Map(); map_is_dict_in_python = { name: 'John', age: 30}
Tuple No tuple in Javascript mytuple = ('apple', 'banana', 'cherry')
export async function getStaticPaths() {
const paths = getAllPostIds();
return {
paths,
fallback: 'blocking',
};
}
export async function getStaticPaths() {
const paths = getAllPostIds();
return {
paths,
fallback: true,
};
}
// Simple fallback page example
function Post({ post }) {
export async function getStaticPaths() {
const paths = getAllPostIds();
return {
paths,
fallback: false,
};
}
export async function getStaticPaths() {
const paths = getAllPostIds();
return {
paths,
fallback: false,
};
}
function getAllPostIds() {
const fileNames = fs.readdirSync(postsDirectory)
@VinayakHegde
VinayakHegde / gh-pages-deploy.md
Created June 2, 2019 19:30 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

var counterPart = (function(){
var counter = 0;
function increaseCounter(){
counter++;
}
function decreaseCounter() {
counter--;
}
function resetCounter() {
counter = 0;
@VinayakHegde
VinayakHegde / modulePattern.js
Created October 17, 2017 18:57
JavaScript Patterns - Module Pattern
var counterPart = (function(){
var counter = 0;
return {
reset : function(){
counter = 0;
this.display();
},
increase : function(){
function defineProperty(obj, prop, value){
var desc = {
value : value,
writable : true,
enumerable : true,
configurable : true
};
Object.defineProperty(obj, prop, desc);
}