require 'uri'
=> true
irb(main):002:0> URI.escape("http://maps.yandex.ru/?text=сбербанк&sll=50.18633499999997%2C53.216120999997734&sspn=0.377655%2C0.123853&z=12&results=20&ll=50.186333%2C53.216119&spn=0.377655%2C0.123853&l=map")
=> "http://maps.yandex.ru/?text=%D1%81%D0%B1%D0%B5%D1%80%D0%B1%D0%B0%D0%BD%D0%BA&sll=50.18633499999997%252C53.216120999997734&sspn=0.377655%252C0.123853&z=12&results=20&ll=50.186333%252C53.216119&spn=0.377655%252C0.123853&l=map"URI.escape нормально отрабатывает. enable_starttls_auto: trueconfig.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: '***************',
user_name: '***************',
password: '*******************',
authentication: 'plain',
enable_starttls_auto: true
} create создаёт обьект из переданных параметров и сразу сохраняет его, так что добавление потом @comment.user = current_usercreate используйте build и сохраняйте руками@comment.save@comment = @post.comments.build(comment_params)
@comment.user = current_user
@comment.save * * * * * /home/user/.rbenv/versions/2.1.0/bin/ruby /home/user/scripts/shoot_my_leg.rb.rbenv нужно поставить интерпретатор из .rvm папки@feed_items = @category.posts.where(status: params[то что придёт от юзера]).paginate(page: params[:page]) public class Main {
private static int period = 60; //Default period
private static final TimeUnit PERIOD_TIME_UNIT = TimeUnit.MINUTES;
public static void main(String[] args) {
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
System.out.println(String.format("Worker work period %d %s", period, PERIOD_TIME_UNIT));
scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
//код который должен запускатся по таймеру
}
}, 0, period, TimeUnit.MINUTES);
}
}ThreadPoolExecutor собственно для этого у меня есть само писанный наподобие андроидовского AsyncTask класс с callback'ами onPostExecuteonPreExecutedoInBackground, которому отдаёшь Runnable он их выполняет. AndroidManifest.xml выставить флаг android:noHistory="true"LoginActivity тогда активити не будет присутствовать в цепочке history.<activity
android:name="ru.habrahabr.toster.LoginActivity"
android:label="@string/title_activity_login"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity> @Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(unique = true, nullable = false)
private String userName
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
private Set<Todo> todos = new HashSet<Todo>();
}@Entity
public class Todo {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne()
@JoinColumn(name = "user_id")
private User user;
} public enum MessageType {
NOTNULL("not null!!!"), MINVALUE("min value must be ...");
private final String message;
private MessageType(final String message) {
this.message = message;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
return this.message;
}
}@NotNull(message = MessageType.NOTNULL.getMessage())
private String userName;MessageType.NOTNULL.name() метод который возвращает имя Enum'a не пройдёт.public class ValidationConstants {
private ValidationConstants() {} //Приватный конструктор, что бы нельзя было сделать new
public static final String NOT_NULL = "Not nuull...";
public static final String MIN_VALUE = "Min value must be...";
}@NotNull(message = ValidationConstants.NOT_NULL) HttpSession session = request.getSession();
session.setAttribute("key", "value"); // положить в сессию что тоsession.getAttribute(key);request.getSession(); Создаст сессию если таковой нет или вернёт уже существующую.request.getSession(true); Вернёт существующую сессию или null если таковой нет.session.setMaxInactiveInterval(30*60); можно задать сколько сессия будет жить в данном случае 30мин.JSESSIONID где хранится id сессииsession.getId();session.invalidate();HttpSession public static final EventExecutorGroup group = new DefaultEventExecutorGroup(16);
pipeline.addLast(group, "handler", new MyBusinessLogicHandler());message.setHeader("Content-Type", "text/plain; charset=utf-8"); raw папке.MediaPlayer. ActionController::Live для этого, чем трогать сервер каждые 5 сек. Когда запись добавится, через ActionController::Live сможете дёрнуть клиента и обновить данные. Погуглите в эту сторону.