Skip to content

Instantly share code, notes, and snippets.

View Ikhiloya's full-sized avatar

Ikhiloya Ikhiloya

View GitHub Profile
@Ikhiloya
Ikhiloya / remove_duplicates.py
Created November 3, 2018 07:17
Removing duplicates from a list
def remove_duplicates(numbers):
duplicates = []
for num in numbers:
if(num not in duplicates):
duplicates.append(num)
return duplicates
remove_duplicates([1, 1, 2, 2])
@Ikhiloya
Ikhiloya / median.py
Created November 3, 2018 07:35
calculates the median of a list of numbers
def median(numbers):
sorted_numbers= sorted(numbers)
size = len(sorted_numbers)
median = 0
if(size % 2 == 0):
index_1 = size/2
print index_1
index_2 = index_1 -1
print index_2
sum =(sorted_numbers[index_1] + sorted_numbers[index_2])
@Ikhiloya
Ikhiloya / garbled.py
Created November 3, 2018 09:40
list filtering with lambda expression and slicing
garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"
message = filter(lambda x: x != 'X' , garbled)
print message
garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
message = garbled[::-1][::2]
print message
@Ikhiloya
Ikhiloya / Apache Poi Dependency(new)
Created November 7, 2018 08:33
Dependencies for Apache Excel Reader
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
@Ikhiloya
Ikhiloya / LocaleConfiguration.java
Last active November 13, 2018 07:06
Spring Boot Internalization Configuration Class
/**
* Configuration class for Internationalization
*/
@Configuration
public class LocaleConfiguration implements WebMvcConfigurer {
/**
* * @return default Locale set by the user
*/
@Bean(name = "localeResolver")
@Ikhiloya
Ikhiloya / i18nController.java
Last active November 11, 2018 13:39
Controller method to test spring boot internalization
@Autowired
MessageSource messageSource;
@RequestMapping(value = "/get-greeting", method = RequestMethod.GET)
public String greeting() {
/**
* @LocaleContextHolder.getLocale()
* Return the Locale associated with the given user context,if any, or the system default Locale otherwise.
* This is effectively a replacement for Locale.getDefault(), able to optionally respect a user-level Locale setting.
*/
@Ikhiloya
Ikhiloya / getMessage.java
Last active November 11, 2018 13:43
Spring boot Internationalization message source method
messageSource.getMessage(String key, @Nullable Object[] params, Locale locale)
@Ikhiloya
Ikhiloya / i18nControllerWithParams.java
Last active November 13, 2018 07:33
controller method for spring boot internalization with an array
@Autowired
MessageSource messageSource;
@RequestMapping(value = "/get-greeting-name", method = RequestMethod.GET)
public String greetingWithName() {
String[] params = new String[]{"Ikhiloya", "today"};
return messageSource.getMessage("good.morning.name", params, LocaleContextHolder.getLocale());
}
@Ikhiloya
Ikhiloya / responsecheck.ts
Created November 26, 2018 11:02
response check
async loadAllFindingsByDate(fromDate, toDate) {
const link = loadAllFindingsByDate.apiUrl;
const data = {
fromDate: fromDate,
toDate: toDate
};
const resp = await this.dataService.funcPost(link, data);
@Ikhiloya
Ikhiloya / ApiResponse.java
Last active April 29, 2020 15:40 — forked from AkshayChordiya/ApiResponse.java
LiveData adapter for Retrofit
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;