Skip to content

Instantly share code, notes, and snippets.

View amelieykw's full-sized avatar

amelieykw amelieykw

  • Sophia Antipolis, France
View GitHub Profile
@amelieykw
amelieykw / 0 - Table of Contents.md
Last active July 16, 2018 22:29
[Java - ArrayList Add/Remove] #ArrayList #Java #tutorial #interview #add #remove
  • Add element to ArrayList
  • Add element at particular index of ArrayList
  • Append Collection elements to ArrayList
  • Copy All List elements to ArrayList
  • Insert all the collection elements to the specified position in ArrayList
  • Remove element from the specified index in ArrayList
  • Remove specified element from ArrayList
@amelieykw
amelieykw / 0 - Table of Contents.md
Last active July 16, 2018 19:07
[Java - ArrayList Sorting] #Java #ArrayList #Sorting #tutorial #interview
  • Sort ArrayList
  • Sort ArrayList in Descending order
  • Sort ArrayList of Objects using Comparable and Comparator
@amelieykw
amelieykw / 2 - How to initialize an ArrayList.md
Last active July 16, 2018 18:42
[Java - ArrayList Basic]#Java #ArrayList #tutorial #interview

Method 1: Initialization using Arrays.asList

Syntax:

ArrayList<Type> obj = new ArrayList<Type>(Arrays.asList(Object o1, Object o2, Object o3, ....so on));

Example:

import java.util.*;
public class InitializationExample1 {
   public static void main(String args[]) {
@amelieykw
amelieykw / 0 - Table of Contents.md
Last active July 17, 2018 07:04
[Java - Java Collections] #Java #Collections #tutorial #interview #ArrayList #LinkedList #Vector #HashSet #LinkedHashSet #TreeSet #HashMap #TreeMap #LinkedHashMap #Hashtable #IteratorandListIterator #ComparableandComparator #JavaCollectionsInterviewQuestions
  1. ArrayList
  2. LinkedList
  3. Vector
  4. HashSet
  5. LinkedHashSet
  6. TreeSet
  7. HashMap
  8. TreeMap
  9. LinkedHashMap
  10. Hashtable
@amelieykw
amelieykw / 0 - Table of Contents.md
Last active July 16, 2018 13:38
[Python - Django and AJAX Form Submissions – Say 'Goodbye' to the Page Refresh] #Python #Django #Ajax #Form #Submission #pageRefresh
  • Use Protection
  • Handling Events
  • Adding AJAX
    • Update main.js:
    • Update forms.py:
    • Update main.js:
    • Update the views
    • Updating the DOM
    • Update the template
    • Update main.js
@amelieykw
amelieykw / How to Work With AJAX Request With Django.md
Last active July 16, 2018 12:10
[Django Ajax] #Python #Django #Ajax

Initial Setup

# base.html

{% load static %}<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{% block title %}Default Title{% endblock %}</title>
 
@amelieykw
amelieykw / Returning Multiple Values in Python.md
Last active July 15, 2018 20:22
[Python - Returning Multiple Values in Python] #Python #tutorial #interview

1) Using Object:

# A Python program to to return multiple 
# values from a method using class
class Test:
    def __init__(self):
        self.str = "geeksforgeeks"
        self.x = 20  
 
# This function returns an object of Test
@amelieykw
amelieykw / When to use yield instead of return in Python?.md
Last active July 15, 2018 20:10
[Python - When to use yield instead of return in Python?] #Python #yield #tutorial #interview

The yield statement suspends function’s execution and sends a value back to caller, but retains enough state to enable function to resume where it is left off.

When resumed, the function continues execution immediately after the last yield run.

This allows its code to produce a series of values over time, rather them computing them at once and sending them back like a list.

# A Simple Python program to demonstrate working
# of yield
 
@amelieykw
amelieykw / How to write an empty function in Python – pass statement?.md
Created July 15, 2018 19:52
[Python - How to write an empty function in Python – pass statement?] #Python #tutorial #interview #emptyfunction #passStatement

In C/C++ and Java, we can write empty function as following

// An empty function in C/C++/Java
void fun() {  }

In Python, if we write something like following in Python, it would produce compiler error.

# Incorrect empty function in Python
def fun(): 
@amelieykw
amelieykw / 1 - Background.md
Created July 15, 2018 18:57
[Python - Function Decorators] #Python #Function #Decorator #tutorial #interview
  1. In Python, we can define a function inside another function.
  2. In Python, a function can be passed as parameter to another function
  3. In Python, a function can also return another function
# A Python program to demonstrate that a function
# can be defined inside another function and a
# function can be passed as parameter.
 
# Adds a welcome message to the string