Skip to content

Instantly share code, notes, and snippets.

View Yogendra0Sharma's full-sized avatar
🎯
Focusing

Yogendra Sharma Yogendra0Sharma

🎯
Focusing
View GitHub Profile

Module

  • Module: a file containing Python definitions and statements

  • File name is the module name, suffix .py

  • Module's name available as the global variable __name__

     # suppose we created a module called fib, which has two function fib and fib2
     # fib prints Fibonacci series up to n
     # fib2 returns Fibonacci series up to n

Input and Output

1. Output Formatting

  • str.format(): control formatting of output

  • str(): return representations of values, which are human-readable

  • repr(): genertate representations, readable by the interpreter

  • Many values have the same representation using either function. However, strings and float point numbers have distinct representations

     s = 'Hello, world.'

Errors and Exceptions

1. Handle Exceptions

  • try ... except
while True:
	try:
		x = int(raw_input("Please enter a number: "))
		break

Classes

  • class members (including data members) are public

  • all member functions are virtual

  • method function,

    • declared with an explicit first argument representing the object
    • the object is provided implicitly by the function call
  • classes are objects

  • Built-in types can be used as base classes

  • Operator overloading supported

Data Structures

1. Lists

  1. list.append(x), list[len(list):] = [x]
  2. list.extend(L), list[len(list):] = L
  3. list.insert(i, x)
  4. list.remove(x)
  5. list.pop(i), i is optional, if i is not specified, removes last one
  6. list.index(x)
  7. list.count(x)
@Yogendra0Sharma
Yogendra0Sharma / react-native-maps-enable-google-maps-instructions.md
Created February 20, 2017 04:33 — forked from kjng/react-native-maps-enable-google-maps-instructions.md
Visual instructions how to enable Google Maps on IOS using react-native-maps

Visual instructions how to enable Google Maps on IOS using react-native-maps

This is for my personal use, things might not be correctly explained here. For the official docs please check https://github.com/airbnb/react-native-maps

Steps from scratch:

1.react-native init GoogleMapPlayground

2. cd GoogleMapPlayground

@Yogendra0Sharma
Yogendra0Sharma / README.md
Created February 20, 2017 04:30 — forked from jesstelford/README.md
Starving the Event Loop with Microtasks

Starving the Event Loop with microtasks

Sparked from this twitter conversation when talking about doing fast async rendering of declarative UIs in Preact

These examples show how it's possible to starve the main event loop with microtasks (because the microtask queue is emptied at the end of every item in the event loop queue). Note that these are contrived examples, but can be reflective of situations where Promises are incorrectly expected to yield to the event loop "because they're async".

  • setTimeout-only.js is there to form a baseline
  • chained-promises.js shows the event loop being starved when many microtasks are queued at once
  • promises-returning-promises.js shows chained .then() calls starving the event loop
@Yogendra0Sharma
Yogendra0Sharma / event-loop.md
Created February 20, 2017 04:29 — forked from nick-brown/event-loop.md
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Yogendra0Sharma
Yogendra0Sharma / jenkins-notes.md
Created February 18, 2017 08:01 — forked from caiquemmf/jenkins-notes.md
Jenkins setup

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins