Skip to content

Instantly share code, notes, and snippets.

View EduardoSaverin's full-sized avatar
:octocat:
Happy Code

Sumit Chaudhary EduardoSaverin

:octocat:
Happy Code
View GitHub Profile
@EduardoSaverin
EduardoSaverin / java9interfaceprivate
Last active November 3, 2021 13:50
interfaceprivatemethod
// Non Static Method Example
public interface Foo {
default void bar() {
System.out.print("Hello");
baz();
}
private void baz() {
System.out.println(" world!");
@EduardoSaverin
EduardoSaverin / List.of()
Last active November 3, 2021 13:25
java9list
List<String> list=List.of("apple","bat");
List<String> list=List.of("apple",null); // It doesn't allow null values - NullPointerException will be thrown if added.
_MangledGlobal__mangled = "From Global"
class MangledGlobal:
def test(self):
return __mangled # Do notice we havn't used self here
print(MangledGlobal().test()) # Prints "From Global"
@EduardoSaverin
EduardoSaverin / stopwords.txt
Created April 11, 2020 03:52
NLTK English Stopwords
i
me
my
myself
we
our
ours
ourselves
you
your
@EduardoSaverin
EduardoSaverin / solrconfig.xml
Created October 5, 2019 02:49
SOLR Infix Suggestor
<config>
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">AnalyzingInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">headline</str>
<str name="suggestAnalyzerFieldType">text_en</str>
<str name="buildOnStartup">false</str>
</lst>
@EduardoSaverin
EduardoSaverin / LoginForm.js
Created July 8, 2018 09:32
Material UI React Login Form
import React from 'react';
import { Paper, withStyles, Grid, TextField, Button, FormControlLabel, Checkbox } from '@material-ui/core';
import { Face, Fingerprint } from '@material-ui/icons'
const styles = theme => ({
margin: {
margin: theme.spacing.unit * 2,
},
padding: {
padding: theme.spacing.unit
}
@EduardoSaverin
EduardoSaverin / promise-chaining.js
Created June 19, 2018 17:26
Example for Promise Chaining
const wait = time => new Promise(
res => setTimeout(() => res(), time)
);
wait(200)
// onFulfilled() can return a new promise, `x`
.then(() => new Promise(res => res('foo')))
// the next promise will assume the state of `x`
.then(a => a)
// Above we returned the unwrapped value of `x`
@EduardoSaverin
EduardoSaverin / clone.js
Created June 19, 2018 14:13
File Clone creation using ES6 generator though it copies itself it can be modified to copy other files.
"use strict";
const fs = require('fs');
const path = require('path');
function clone(generatorFunction) {
function callback(err) {
if (err) {
return generator.throw(err);
}
const results = [].slice.call(arguments, 1);
@EduardoSaverin
EduardoSaverin / Object.create.js
Last active February 14, 2018 13:25
Showing Inheritance using Object.create and `new` Operator
// Shape - superclass
function Shape() {
this.x = 0;
this.y = 0;
}
// Superclass method
Shape.prototype.move = function(x, y) {
this.x += x;
this.y += y;
const redux = require('redux');
const createStore = redux.createStore;
const initialState = {
counter:0
}
// Order matters Reducer -> Store -> Subscription -> dispatcher
// Reducer