Skip to content

Instantly share code, notes, and snippets.

View imarban's full-sized avatar
🎯
Focusing

IM imarban

🎯
Focusing
View GitHub Profile
@imarban
imarban / permutations-python
Last active August 27, 2015 23:42
Get all the permutations of a word
This code aims to get all the permutations of a word.
e.g. If the "abc" string is received, the otuput will be ["abc", "bca", "cba", "cab", "acb", "bac"]
@imarban
imarban / parent.xml
Created November 10, 2015 18:33
Starter Parent Pom Spring Boot
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
</parent>
@imarban
imarban / dependency.xml
Created November 10, 2015 18:36
Depedency Spring Boot Starter Web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
@imarban
imarban / SampleController.java
Last active November 10, 2015 18:39
First Controller Spring Boot
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
public class Vehicle {
private Engine engine;
private Transmission transmission;
public Vehicle(Engine engine, Transmission transmission) {
this.engine = engine;
this.transmission = transmission;
}
}
public class Vehicle {
private Engine engine = new TurboEngine();
private Transmission transmission = DSGTransmission();
}
class Transmission:
pass
class Engine:
pass
class Vehicle:
def __init__(self, engine, transmission):
self.engine = engine
self.transmission = transmission
def save_last_login(user, get_now):
datetime_now = get_now()
save(user, datetime_now)
class TextProcessor:
def __init__(self, text, tokenizer_module, sanitizer_module):
self.text = text
self.tokenizer = tokenizer_module
self.sanitizer = sanitizer_module
def get_tokens():
sanitized = self.sanitizer.sanitize(self.text)
tokens = self.tokenizer.tokenize(sanitized)
return tokens
class WirelessPrinter:
def __init__(ip):
self.ip = ip
def print_now(report):
open_connection()
report.prepare_for_print()
# Code required to print to an actual printer
close_connection()