Skip to content

Instantly share code, notes, and snippets.

View meetzaveri's full-sized avatar
🐞
Debugging

Meet Zaveri meetzaveri

🐞
Debugging
View GitHub Profile
@meetzaveri
meetzaveri / Scrape_out_value_from_key-value.js
Created January 17, 2018 07:13
This snippet performs the function of taking out value from key-value pair(Objects) and storing them in an array.
const enumarr = Object.entries(this.state);
const newarr = [];
for(let i = 0; i<=enumarr.length - 1 ;i++){
newarr.push(enumarr[i][1]);
}

Vue.js 2 Lifecycle hooks

beforeCreate() : This method is called synchronously after the Vue instance has just been initialized, before data observation and event/watcher setup.

created() : This method is called synchronously after the Vue instance is created. Data observation, computed properties, methods and event callbacks have already been set up at this stage but the mounting phase has not started yet.

beforeMount() : This method is called right before the component is mounted. So it is called before the render method is executed.

mounted() : This method is called after the component has just been mounted.

@meetzaveri
meetzaveri / dynamodbcheatsheets.md
Last active February 14, 2019 11:17
DynamoDB CheatSheets

CheatSheet for DynamoDB

Creating Data

PutItem – Writes a single item to a table. You must specify the primary key attributes, but you don't have to specify other attributes.

BatchWriteItem – Writes up to 25 items to a table. This is more efficient than calling PutItem multiple times because your application only needs a single network round trip to write the items. You can also use BatchWriteItem for deleting multiple items from one or more tables.

Reading Data

GetItem – Retrieves a single item from a table. You must specify the primary key for the item that you want. You can retrieve the entire item, or just a subset of its attributes.

BatchGetItem – Retrieves up to 100 items from one or more tables. This is more efficient than calling GetItem multiple times because your application only needs a single network round trip to read the items.

Regex Patterns

  • . - Any Character Except New Line
  • \d - Digit (0-9)
  • \D - Not a Digit (0-9)
  • \w - Word Character (a-z, A-Z, 0-9, _)
  • \W - Not a Word Character
  • \s - Whitespace (space, tab, newline)
  • \S - Not Whitespace (space, tab, newline)

Example (Vue)

How to use 'refs' in order to refer to DOM element in Vue.

<template>
  <p ref="dom-element">{{counter}}</p>
</template>
<script>
export default {
 data() {
# Searching an element in a list/array in python
# can be simply done using 'in' operator
# Example:
# if x in arr:
# print arr.index(x)
# If you want to implement Linear Search in python
# Linearly search x in arr[]
# If x is present then return its location
var invalidChar = 'b';
var arr = [ 'a', 'b', 'b', 'd', 'e' ];
var ptr = 0, n = arr.Length;
for (int i = 0; i < N; i++){
if (arr[i] != invalidChar) {
arr[ptr] = arr[i];
ptr++;
}
}
# Python Program for recursive binary search.
# Returns index of x in arr if present, else -1
def binarySearch (arr, l, r, x):
# Check base case
if r >= l:
mid = l + (r - l)/2
# Python program for implementation of Insertion Sort
# Function to do insertion sort
def insertionSort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]