This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class UserService { | |
public Observable<User> findAll() { | |
return Observable.<User>from(new User[] {new User("Shazin", 29), new User("Shahim", 29)}); | |
} | |
public Observable<User> findByName(String name) { | |
return findAll().filter(u -> u.getName().toLowerCase().contains(name.toLowerCase())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/user") | |
public class UserController { | |
@Autowired | |
private UserService userService; | |
@RequestMapping(method = RequestMethod.GET) | |
public Observable<List<User>> find() { | |
return userService.findAll().toList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ObservableReturnValueHandler implements HandlerMethodReturnValueHandler { | |
public boolean supportsReturnType(MethodParameter returnType) { | |
Class parameterType = returnType.getParameterType(); | |
return Observable.class.isAssignableFrom(parameterType); | |
} | |
public void handleReturnValue(Object returnValue, | |
MethodParameter returnType, ModelAndViewContainer mavContainer, | |
NativeWebRequest webRequest) throws Exception { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(method = RequestMethod.GET, value = "/{video:.+}") | |
public StreamingResponseBody stream(@PathVariable String video) | |
throws FileNotFoundException { | |
File videoFile = videos.get(video); | |
final InputStream videoFileStream = new FileInputStream(videoFile); | |
return (os) -> { | |
readAndWrite(videoFileStream, os); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public static class WebConfig extends WebMvcConfigurerAdapter { | |
@Override | |
public void configureAsyncSupport(AsyncSupportConfigurer configurer) { | |
configurer.setDefaultTimeout(-1); | |
configurer.setTaskExecutor(asyncTaskExecutor()); | |
} | |
@Bean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dht.h> | |
#include <LiquidCrystal.h> | |
#define DHT11_PIN 8 | |
dht DHT; | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
void setup() { | |
lcd.begin(8, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################## | |
# Shazin Sadakath # | |
####################### | |
import RPi.GPIO as GPIO | |
import time | |
import telegram | |
from subprocess import call | |
sensor = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo myservo; // create servo object to control a servo | |
// twelve servo objects can be created on most boards | |
int pos = 0; // variable to store the servo position | |
int times = 5; | |
int seconds = 0; | |
int thresholdSeconds = 21600; // Every 6 Hours |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example to demonstrate thread definition, semaphores, and thread sleep. | |
#include <ChibiOS_AVR.h> | |
#include <LiquidCrystal.h> | |
#include <dht.h> | |
#define DHT11_PIN 8 | |
int humidity = 0; | |
int temperature = 0; | |
dht DHT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ModuleName { // module name | |
requires {modifier} ModuleName; // dependences | |
exports PackageName [to ModuleName {, ModuleName}]; // exports | |
opens PackageName [to ModuleName {, ModuleName}]; // open for reflection | |
} |
OlderNewer