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
@ManyToMany | |
private List<Project> projects; |
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 CredentialsProvider { | |
public static Credential authorize() { | |
try { | |
return GoogleCredential.fromStream(CredentialsProvider.class.getClassLoader() | |
.getResourceAsStream("client-secrets.json")) | |
.createScoped(Collections.singleton(StorageScopes.CLOUD_PLATFORM)); | |
} catch (IOException e) { | |
Throwables.propagate(e); | |
} | |
return null; |
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
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
http | |
.authorizeRequests() | |
.antMatchers("/").permitAll() | |
.antMatchers("/loggeduser").authenticated() | |
.and().formLogin(); | |
} |
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 Fibonacci { | |
private static class FibonacciGenerator { | |
private BigInteger nMinusTwo = BigInteger.ONE; | |
private BigInteger nMinusOne = BigInteger.ZERO; | |
public BigInteger next() { | |
final BigInteger n = nMinusTwo.add(nMinusOne); | |
nMinusTwo = nMinusOne; |
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
from __future__ import unicode_literals | |
import common.functions | |
from django.db import migrations, models | |
def uniquify_keys_for_events(apps, schema_editor): | |
events = apps.get_model("event", "Event").objects.all() | |
for event in events: | |
event.key = common.functions.generate_random_string_32() | |
event.save() |
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
def add_arguments(self, parser): | |
parser.add_argument('-d', '--display', | |
action='store_true', | |
default=False, | |
dest='show', | |
help='display text') |
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
@Column | |
@Type(type = "pl.mloza.hibernate.CustomType") | |
private JsonbObject jsonbObject; |
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
@Controller | |
public class UploadController { | |
@PostMapping("/upload") | |
@ResponseBody // 1 | |
public String handleFile(@RequestPart(name = "fileupload") MultipartFile file) { // 2 | |
File uploadDirectory = new File("uploads"); | |
uploadDirectory.mkdirs(); // 3 | |
File oFile = new File("uploads/" + file.getOriginalFilename()); |
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
@ComponentScan(basePackageClasses = {MainController.class, WebAppConfiguration.class}) |
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
from django.contrib.auth.models import User | |
from django.contrib.staticfiles.testing import StaticLiveServerTestCase | |
from selenium.webdriver.firefox.webdriver import WebDriver | |
from selenium.webdriver.support.wait import WebDriverWait | |
class AuthenticationTests(StaticLiveServerTestCase): | |
def __init__(self, methodName='runTest'): | |
super().__init__(methodName='runTest') |