Skip to content

Instantly share code, notes, and snippets.

View fedotxxl's full-sized avatar

Fedor Belov fedotxxl

View GitHub Profile
angular.module("app")
.factory("_authInterceptor", function($q, _authStorage) {
return {
request: function (req) {
req.headers["X-Access-Control-Token"] = _authStorage.get().token;
return req;
},
responseError: function(rejection) {
var status = rejection.status;
import org.skife.jdbi.v2.StatementContext
import org.skife.jdbi.v2.tweak.ResultSetMapper
import java.sql.ResultSet
import java.sql.SQLException
/**
* Created by fbelov on 17.03.15.
*/
class MapJdbiMapper implements ResultSetMapper<Map> {
List<Object[]> params = links
.stream()
.map(o -> new Object[] {o.getTagId(), o.getTagOriginalId()})
.collect(Collectors.toList());
jdbcTemplate.batchUpdate("UPDATE tag_original SET tag_id = ? WHERE id = ?", params);
//ng-bind-html="page.html | to_trusted"
angular.module("common")
.filter("to_trusted", function ($sce) {
return function (text) {
return $sce.trustAsHtml(text);
};
});
Condition condition;
List<ConsumedDvdWithTotal> answer;
Map<String, Object> bindParams = new HashMap<>();
List<Condition> conditions = new ArrayList<>();
if (params.hasYear()) {
condition = condition("EXTRACT(YEAR FROM date_released) = :year");
bindParams.put("year", params.getYear());
if (params.hasMonth()) {
client = ClientBuilder.newClient();
client.register(new LoggingFilter());
client.property(ClientProperties.CONNECT_TIMEOUT, timeoutInMillis);
client.property(ClientProperties.READ_TIMEOUT, timeoutInMillis);
@Component
@Provider
public class SiteWithParamsConverterProvider implements ParamConverterProvider {
@Autowired
private Converter converter;
@Override
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
if (genericType.equals(SiteWithParams.class)) {
package com.devadmin.ta.domain;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.QueryParam;
/**
* Created by fbelov on 4/16/16.
*/
public class QueryParamWithDefaultValueRequest {
//<import resource="applicationContext.log.db.${log.to.db:false}.xml"/>
//http://stackoverflow.com/questions/3035630/how-to-achieve-conditional-resource-import-in-a-spring-xml-context
private void loadConditionalProperties() {
try {
Properties properties = new Properties();
try (InputStream stream = FileUtils.openInputStream(new File(getDefaultConfigPath()))) {
properties.load(stream);
}
<!-- http://stackoverflow.com/a/36707798 -->
<appender name="main" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/http-file-cache/cache.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] [%X] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>/var/log/http-file-cache/cache.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>