我需要将每个单词的第一个字符设为大写字母,然后将其余字母设为小写字母...
manufacturer.MFA_BRAND.first.upcase
Run Code Online (Sandbox Code Playgroud)
只设置第一个字母大写,但我需要这个:
ALFA ROMEO => Alfa Romeo
AUDI => Audi
BMW => Bmw
ONETWO THREE FOUR => Onetwo Three Four
Run Code Online (Sandbox Code Playgroud) 如何在java中切片?我从csv和xls获取行,并且例如单元格中的数据就像
14.015_AUDI
我怎么能说java之前必须只看部分_?所以操纵后我必须有14.015.在rails中我会用gsub做这个,但是在java中这是怎么做的?
如何为我的IdClient字段设置主键?我已经尝试了所有方法,但我会收到错误(rails 3.0.9)...你能帮帮我吗?
class CreateCustomers < ActiveRecord::Migration
def self.up
create_table :customers do |t|
t.integer :IdCustomer
t.string :username
t.string :crypted_password
t.string :password_salt
t.string :persistence_token
t.string :email
t.string :Skype
t.string :ICQ
t.string :Firstname
t.string :Lastname
t.string :Country
t.string :State
t.string :City
t.string :Street
t.string :Building
t.integer :Room
t.string :AddressNote
t.date :DateOfReg
t.integer :CustGroup
t.float :TotalBuy
t.timestamps
add_index(:customers, :IdCustomer, :unique => true)
end
end
def self.down
drop_table :customers
end
end
Run Code Online (Sandbox Code Playgroud)
还有如何在模型中设置关系?
我打算做这样的架构:
store
book
in store
- 我有一个服务调用,从服务中获取数据,我对结果进行订阅.就像在angular2 docs(http)中描述的那样.
我想在嵌套组件中使用这些数据:form(formBuilder
),材料设计元素等.
哪种方式最好,这样做?我是angular2的新手.
商店:
book: IBook;
constructor(private bookService: BookService) { }
ngOnInit() {
this.bookService.getBook('1')
.subscribe((book) => {
this.book = book;
});
}
Run Code Online (Sandbox Code Playgroud)
bookService的:
...
getBook (id): Observable<IBook> {
return this.http.get(this.url + '/' + id)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || { };
}
...
Run Code Online (Sandbox Code Playgroud)
书:
@Input() book:IBook;
constructor() {}
ngOnInit() {
/*How here can i subscribe on book http data …
Run Code Online (Sandbox Code Playgroud) 我需要将图像从recaptcha保存到localhost磁盘,我使用watir-webdriver获取图像dom元素,但它不支持save方法,就像watir一样.那么如何将图像保存到我的磁盘?HTML:
<div id="recaptcha_image" style="width: 300px; height: 57px;">
<img style="display:block;" alt="???????? ?? ????? reCAPTCHA" height="57" width="300" src="https://www.google.com/recaptcha/api/image?c=03AHJ_VusSUxF0IYURRcVTVTjJJnUk92j-hXYsuwqvu0m5tvKFzAnwvrHlz-j_Gfqg-sUrHLj3D2DrUYNNg4uvr2BNgZqlK5vpJUJVYkkWo36I4RRmRGkYZru5kBYhzPCCn49KlH6wW_iLw6vIzv7vnhpu6ndqxb-9SkIRrVYyBwN39kg18Lov7Hc">
</div>
Run Code Online (Sandbox Code Playgroud)
和红宝石代码:
cap = @browsers[i].div(:id => 'recaptcha_image').image
Run Code Online (Sandbox Code Playgroud)
如何将图像文件保存到磁盘?
我想导入大量的cvs数据(不是直接导入AR,但经过一些提取后),而且我的代码非常慢.
def csv_import
require 'csv'
file = File.open("/#{Rails.public_path}/uploads/shate.csv")
csv = CSV.open(file, "r:ISO-8859-15:UTF-8", {:col_sep => ";", :row_sep => :auto, :headers => :first_row})
csv.each do |row|
#ename,esupp= row[1].split(/_/)
#(ename,esupp,foo) = row[1]..split('_')
abrakadabra = row[0].to_s()
(ename,esupp) = abrakadabra.split(/_/)
eprice = row[6]
eqnt = row[1]
# logger.info("1) ")
# logger.info(ename)
# logger.info("---")
# logger.info(esupp)
#----
#ename = row[4]
#eprice = row[7]
#eqnt = row[10]
#esupp = row[12]
if ename.present? && ename.size>3
search_condition = "*" + ename.upcase + "*"
if esupp.present?
#supplier = @suppliers.find{|item| item['SUP_BRAND'] …
Run Code Online (Sandbox Code Playgroud) 我在我的rails应用程序中使用jstree,我正在使用json数据,但我遇到了麻烦:我如何设置节点链接和href为它,以便我可以继续下去?Json看起来像这样:
var data = [
{
"data":"\u041b\u0435\u0433\u043a\u043e\u0432\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0438",
"href":10001,
"children":[
{
"data":"\u041a\u0443\u0437\u043e\u0432",
"href":10101,
"children":[
{
"data":"\u0422\u043e\u043f\u043b\u0438\u0432\u043d\u044b\u0439 \u0431\u0430\u043a / \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0443\u044e\u0449\u0438\u0435",
"href":10316
},
{
"data":"\u041a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0434\u0438\u0430\u0442\u043e\u0440\u0430",
"href":10317
},
{
"data":"\u041e\u0431\u043b\u0438\u0446\u043e\u0432\u043a\u0430 / \u0437\u0430\u0449\u0438\u0442\u0430 / \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435 / \u044d\u043c\u0431\u043b\u0435\u043c\u044b / \u0437\u0430\u0449\u0438\u0442\u0430 \u0440\u0430\u0441\u043f\u044b\u043b.",
"href":10319,
"children":[
{
"data":"\u041e\u0431\u043b\u0438\u0446\u043e\u0432\u043a\u0430/\u0437\u0430\u0449\u0438\u0442\u043d\u0430\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u043a\u0430",
"href":10840
},
{ ................................
Run Code Online (Sandbox Code Playgroud)
和js
$("#tree").jstree({
plugins: ['themes', 'json_data'],
json_data: {data: data},
themes: {
theme: 'apple'
},
});
$('#tree').bind('select_node.jstree', function(e,data) {
window.location.href = "123123"
});
Run Code Online (Sandbox Code Playgroud)
但如果我看到代码,链接有href ="#".怎么了?
在我的 rails 应用程序中,我需要使用现有的 MS SQL 数据库。我曾尝试遵循本手册:
http://rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html
我不知道如何做模型、脚手架等,因为 rails 不能简单地使用另一个 db。我不想为 MS SQL 数据库中的表运行 rake db:migrate。我还需要在模型中写些什么?如果简单:使用 MS SQL 服务器数据库中的表,但我也想解决迁移等问题。
在我的角度4应用程序中,我正在使用ngx-restangular
来处理所有服务器调用.它返回可观察的结果,并且该模块具有处理错误的钩子(如401等).
但是从文档中,我可以处理403(401)所以:
RestangularProvider.addErrorInterceptor((response, subject, responseHandler) => {
if (response.status === 403) {
refreshAccesstoken()
.switchMap(refreshAccesstokenResponse => {
//If you want to change request or make with it some actions and give the request to the repeatRequest func.
//Or you can live it empty and request will be the same.
// update Authorization header
response.request.headers.set('Authorization', 'Bearer ' + refreshAccesstokenResponse)
return response.repeatRequest(response.request);
})
.subscribe(
res => responseHandler(res),
err => subject.error(err)
);
return false; // error handled
}
return true; // error …
Run Code Online (Sandbox Code Playgroud) 我有这么长的HTML代码,当你有旧浏览器时提醒:
<div class="ie-message" style="display: block; ">
<div class="alert error">
<h2>
Sorry, your web-browser is outdated
</h2>
<p>
We recommend you install new version of web-browser
</p>
</div>
<div class="browsers-list">
<div class="browser-button chrome">
<a href="http://www.google.com/chrome">Google Chrome</a>
</div>
<div class="browser-button firefox">
<a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a>
</div>
<div class="browser-button opera">
<a href="http://www.opera.com/download/">Opera</a>
</div>
<div class="browser-button safari">
<a href="http://www.apple.com/safari/download/">Apple Safari</a>
</div>
<div class="browser-button ie">
<a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer</a>
</div>
</div><div class=?"ie-message" style=?"display:? block;? ">?<div class="ie-message" style="display: block; ">
<div class="alert error">
<h2>
Sorry, your web-browser is …
Run Code Online (Sandbox Code Playgroud) ruby ×4
angular ×2
jquery ×2
string ×2
csv ×1
excel ×1
fastercsv ×1
html ×1
java ×1
javascript ×1
json ×1
jstree ×1
migration ×1
observable ×1
odbc ×1
optimization ×1
restangular ×1
rxjs ×1
sql-server ×1
typescript ×1
watir ×1