Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

iOS 发布证书配置

Posted on 2017-08-21 16:06

公司账号
1.先登录公司账号 invite成管理员,点击邮件中链接点选同意

  1. 钥匙串访问:
    钥匙串访问 –> 证书助理 –> 从证书办法机构请求证书 –>生成CSR文件
  2. 到Xcode –> preference –> account 添加apple ID,并选择对应的公司账号
  3. apple developer中 certificates 添加production证书 将CSR文件传上去 下载生成的证书,
    双击点开配置到电脑上
  4. Provisioning Profiles –> distribution 再申请一个证书选择ADhoc
    下载生成的证书双击运行
    ps:现在Xcode中运行的设备必须是配置distribution证书是select的设备

个人账号
1.钥匙串访问:
钥匙串访问 –> 证书助理 –> 从证书办法机构请求证书 –>生成CSR文件
2.申请production证书
3.申请appid(bundle id要跟xcode里面一样)
4.申请distribution证书

web打印

Posted on 2017-08-16 16:34

1.按照说明书将打印机驱动安在电脑上测试,可用之后
2.在需要打印的页面,用
chrome

1
window.print()

IE浏览器

1
mywindow.print()

打印
ps:页眉,页脚,距离边上的边距都在调起打印之后更多设置里面选择设置
页眉: 日期+网页title
页脚: 网址+页数
3
3-1.如果只想打印一部分页面,就在js里面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$("#print_btn").click( function (){
var old_body = $("body").html();

var new_body = $("#print_id").html();

new_body = "<div id='print_id' style='width: 230px'>" + new_body + "</div>" ;
//还可以让取到的html代码加上新的标签 style等
//$("#xxx").html() 和$("#xxx").innerHTML 是一样的。都取不到最外层的div(<div id="xxx"></div>)

window.document.body.innerHTML= new_body;
window.print();

$("body").html(old_body);
})

3-2.如果想要新开一颗窗口去打印的话就用window.open()
ps:1.括号里为空的时候会新开一个tab
新开一个window的话需要window.open(“url”, “name”,”some value”,replace)
window.open官方文档
2.width,height不可以写成活的

注意:
1.打印的某些参数可以写在

1
2
3
<style>
@media print{}
</style>

里面,但是要特别注意空格 多一个都不会识别 所以建议都不要空格 都顶头写
在ruby中要写在application.html.erb的标签里面

2.media是style的一个属性

1
2
3
<style>
@media print{}
</style>

等同于

1
2
<style media="print">
</style>

3.如果想引入一个css文件作为样式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function Popup(data) {
var mywindow = window.open('');
mywindow.document.write('<html><head><title></title>');
mywindow.document.write("<%= j stylesheet_link_tag 'v2_editor', media: 'all'%>");
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.focus();
setTimeout(function(){
mywindow.print();
mywindow.close(); //取消之后会自动关闭窗口
},200);
return true;
}

二代身份证识别仪

Posted on 2017-08-16 14:57

我用的是华旭金卡HX-FDX35,这个是基于WindowsIE浏览器开发的
1.将驱动安上(光盘中的自动安装 双击就安上了)
2.安装测试软件看能不能正常读取
3.布置软件
本地:双击运行active_reg.bat
服务器:将CBA文件夹拷贝到与页面相同的文件夹下面
4.点击JsDemo.html 文件打开测试页面 测试一下
如果好用的话,就将测试页面的代码集成到程序需要的页面上
注意:
1.不要写在form里面
2..标签和

mysql重置密码

Posted on 2017-08-08 10:22

1.停止 MySQL 服务

$ sudo /usr/local/mysql/support-files/mysql.server stop
要是不行的话 就ps -ef | grep mysqld
将进程杀掉就可以了

2.进入安全模式
sudo mysqld_safe –skip-grant-tables
sudo /usr/local/Cellar/mysql/5.7.18_1/bin/mysqld_safe –skip-grant-tables

这个地方,如果你 alias 了 mysqlld_safe 这个命令,那么可以直接复制粘贴;如果没有,则需要加上正确的路径。在 Linux/OS X 系统下,默认路径是 /usr/local/mysql/bin/mysqld/usafe。(/usr/local/Cellar/mysql/5.7.18_1/bin/mysqld_safe)–我的路径

3.启动MySQL服务
$ mysql.server start

4.修改密码
进入了之后先不要急着使用 update 命令修改密码,先看看表中的字段名。不同版本密码的字段名可能不一样。

MySQL 的用户信息是存在 mysql.user 这个表里面的。于是可以先选择 mysql 这个数据库,再看数据库中 user 表中的字段名称。
use mysql; //切换数据库
describe user; //查看user表的字段
然后确定密码字段的名称,一般可能是 Password。然而在 OS X 的 MySQL 5.7 这个版本中,密码字段名称是 authentication_string 。记住这个字段名。

然后修改密码啊:UPDATE mysql.user SET authentication_string=PASSWORD(‘123456’) where User=’root’; //将root用户密码改成 123456

5.刷新权限,使配置生效

flush privileges;
最后再启动 MySQL

x-code ios一些基本配置

Posted on 2017-08-03 15:18

1.配置http请求(可以通过http请求页面):
在info.plist里面加上 App Transport Security Settings
Allow Arbitrary Loads Yes
2.配置最低适配版本:
General –> Development Info –> Development Target
在这个development info 里面可以配置app的基本信息
3.配置app图表和开机画面:
General –> AA Icons and Launch images
只配上面两个source就可以
在Assets.xcassets 里面添加图片
ps:要migrate
4.打包发到蒲公英:
Prduct –> Archive

新建一个ios项目 用x-code

Posted on 2017-08-02 14:21

1.搭建ios项目 create a new project
选择 single view application
然后填写
将项目中的storyboard文件删掉(两个)
将General –> Development Info –> Main Interface中的值删掉
(如果删不掉就将info.plist 文件中的Main Story base name 删掉)
2.在supporting files里面新建一个pch文件
点击最上方那个蓝色的项目图标(xcodeproj)
build settings 里面选择 Prefix Header 配置路径(参考)
3.填写pch文件中应该有的颜色 适配等信息
4.$ pod init —–新建Podfile
$ pod install ———-安装插件
5.新建.gitignore文件 将不要上传的文件写进去
6.之后就用以xcworkspace为后缀的文件打开项目(白的!!!!)
7.在Appdelegate.m里面写进入ipad的默认路径
想要嵌套webview要配置info.plist 详情见x-code的一些基本配置

rails-将数据库中user的password跟h5输入的匹配

Posted on 2017-07-31 10:51

user.valid_password?(params[:password])

rails -- modal

Posted on 2017-07-28 10:16

第一种方法:用gem ‘bootstrap-modal-rails’使用插件
1.首先在index页面中添加按钮(冻结,解冻):

1
2
3
4
5
6
7
8
9
 
<% if user.is_enabled.blank? or user.is_enabled == "ture" %>
<%= link_to_modal freeze_users_path(:id => user.id), id: "freeze", class: 'btn btn-danger', title: "冻结" do %>
<%= t('freeze') %>
<% end %>
<% else%>
<%= link_to t('defreeze'), defreeze_users_path(:id => user.id), method: :post, class: 'btn btn-primary',
data: { confirm: "确定要解冻该用户么?"} %>
<% end %>

2.controller的对应的action
3.设置对应的route路由中。
4.1 重点来了 ,需要调用modal了.首先在gemfile 中添加gem :

1
gem 'bootstrap-modal-rails', '2.2.5'

4.2 在application.js 中添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//= require bootstrap-modal    
//= require bootstrap-modalmanager

$(document).on('click', '[data-toggle=modal-ajax]', function(e) {
e.preventDefault();
e.stopPropagation();
console.info();
$('#modal-ajax').empty().modal().modal('loading');
$.rails.handleRemote($(this));
return false;
});

$(document).on('ajax:beforeSend', '.modal form[data-remote]', function(e) {
return $(this).parents('.modal').modal('loading');
});

4.3 application.css中添加:

1
2
*= require bootstrap-modal    
*= require bootstrap-modal-bs3patch

4.4 helpers/application_helper.rb中添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def link_to_modal(name, options = nil, html_options = nil, &block)
default_options = { data: { toggle: 'modal-ajax', target: '#modal-ajax' } }
if block_given?
link_to(name, default_options.update(options), html_options, &block)
else
link_to(name, options, default_options.update(html_options))
end
end
def modal_header(title)
%(<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>#{title}</h3>
</div>).html_safe
end
def modal_footer(&block)
%(<div class="modal-footer">
#{capture(&block)}
<button type="button" data-dismiss="modal" class="btn">#{t("cancel")}</button>
</div>).html_safe
end

4.5 layouts/application.html.rb中添加:

1
2
<!-- 全局弹出层 -->
<div id="modal-ajax" class="modal hide fade" tabindex="-1"></div>

4.6 在视图层添加 view/users/freeze.js.erb:

1
2
3
$('#modal-ajax').html('<%= j(render 'freeze') %>');
$('#modal-ajax').modal();
$("#modal-ajax").removeClass("hide");

4.7 在视图层添加 view/users/_freeze.html.erb, 在freeze.js.erb中render会渲染这个视图

1
2
3
4
5
<%= modal_header t("freeze_user") %> <%= form_for @user, url: freeze_reason_users_path, :html => { method: 'post'} do |f| %>
<%#= f.radio_button :is_enabled, 'false', :id => 'user_reason', :style => 'margin: 0; margin-top: -22px; margin-left: 20px;', :class=>"stat <%#= f.label :reason, '冻结', :style => 'margin-top: -25px; margin-left: 10px;' %>
<%= f.label t("freeze_reason") %>
<%= f.text_area :reason_of_freeze, :name => "reason", :placeholder => t('freeze_placeholder'), style: "width: 100%; height: 80px; margi
<%= modal_footer do %> <%= f.submit t('global.submit'), class: 'btn btn-primary'%> <% end %> <% end %>

参考原文

第二种方法: gem:jquery-ui-rails 自己写modal
jquery-ui
参考原文
1.安装上jquery-ui之后
2.页面上js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$(function() {
dialog = $( "#dialog" ).dialog({
autoOpen:false,
modal: true,
});
});
//打开弹窗
function open_dialog(url){
dialog.dialog('open');
$.get(url,function(data){
$('#dialog').html(data)
})
}
//关闭弹窗
function close_dialog(){
$('#dialog').dialog('close')
}

html:

1
2
3
 <div id="dialog" title="新建工序" style="display:none"></div>

<%= link_to_function '新增', "open_dialog('/steps/ajax_new_form?craft_id=#{params[:craft_id]}')", id: "opener", class: 'btn btn-primary' %>

关闭按钮:

1
<%= link_to_function '返回', 'close_dialog()', class: "btn btn-default btn-small" %>

注意: rails及以后是不可以直接使用link_to_function的
要在application helper里面 加上

1
2
3
4
5
6
7
8
9
def link_to_function(name, *args, &block)
html_options = args.extract_options!.symbolize_keys

function = block_given?? update_page(&block) : args[0] || ''
onclick ="#{"#{html_options[:onclick]};" if html_options[:onclick]}#{function}; return false;"
href = html_options[:href] || '#'

content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick))
end

highchart

Posted on 2017-07-27 09:40

想添加图表时使用highchart
1.在Gemfile中 添加

1
gem "highcharts-rails"

$ bundle install
2.在application.js中

1
2
//= require highcharts
//= require highcharts/highcharts-more

3.在页面上
HTML:

1
<div id="container" style="min-width:800px;height:400px"></div>

js:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var chart = new Highcharts.Chart('container', {// 图表初始化函数,其中 container 为图表的容器 div               
chart: {
type: 'bar' //指定图表的类型,默认是折线图(line)
},
title: {
text: '我的第一个图表' //指定图表标题
},
xAxis: {
categories: ['苹果', '香蕉', '橙子'] //指定x轴分组
},
yAxis: {
title: {
text: 'something' //指定y轴的标题
}
},
series: [{ //指定数据列
name: '小明', //数据列名
data: [1, 0, 4] //数据
}, {
name: '小红',
data: [5, 7, 3]
}]
});

ps:1.官方文档
2.坑:
1)series中的data必须是数组
如果是从controller中取值:
若取得值为数组则直接输出在rails中<%= @xxx%>
若只有一个值则写成[<%= @xxx%>]
2)xAxis中的categories必须是数组 若在controller中取值 必须用raw

cancancan & 动态权限

Posted on 2017-07-19 16:31

参考参考的参考关于cancancan1
关于cancancan2
关于cancancan3
官方文档
rake permissions:permissions

1…202122…28

Lydia

This is lydia's blog

277 posts
1 categories
46 tags
© 2020 Lydia
Powered by Hexo
|
Theme — NexT.Muse v5.1.4