defaults

Sqlalchemy 事件监听与初始化

 ̄綄美尐妖づ 提交于 2019-12-04 08:00:05
sqlalchemy不仅仅能自动创建数据库,更提供了其他更强大的功能,今天要介绍的就是sqlalchemy中的事件监听,并将其应用到数据库的初始化中。 需求:当插入设置password字段时,自动加密 # -*- coding:utf-8 -*- from sqlalchemy import * from sqlalchemy import event from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import scoped_session, sessionmaker import hashlib #这里定义一个password加密混淆 password_prefix = "Ad%cvcsadefr^!deaf" #定义数据库的账号、端口、密码、数据库名,使用的连接模块,这里用的是mysqldb engine = create_engine( 'mysql+mysqldb://root:1234567@localhost:3306/tech?charset=utf8', echo=False#是否输出数据库操作过程,很方便调试 ) #定义一个函数,用来获取sqlalchemy的session def bindSQL(): return scoped_session

Mac 禁用动画

天涯浪子 提交于 2019-12-04 05:41:57
# opening and closing windows and popovers defaults write -g NSAutomaticWindowAnimationsEnabled -bool false # smooth scrolling defaults write -g NSScrollAnimationEnabled -bool false # showing and hiding sheets, resizing preference windows, zooming windows # float 0 doesn't work defaults write -g NSWindowResizeTime -float 0.001 # opening and closing Quick Look windows defaults write -g QLPanelAnimationDuration -float 0 # rubberband scrolling (doesn't affect web views) defaults write -g NSScrollViewRubberbanding -bool false # resizing windows before and after showing the version browser # also

TypeScript 解构

时光怂恿深爱的人放手 提交于 2019-12-04 04:04:39
⒈解构数组   最简单的解构莫过于数组的解构赋值了: let input = [1, 2]; let [first, second] = input; console.log(first); // outputs 1 console.log(second); // outputs 2   这创建了2个命名变量 first 和 second 。 等价于下面使用了索引的代码,但更为方便: first = input[0]; second = input[1];   解构作用于已声明的变量会更好: // swap variables [first, second] = [second, first];   作用于函数参数: function f([first, second]: [number, number]) { console.log(first); console.log(second); } f(input);   你可以在数组里使用 ... 语法创建剩余变量: let [first, ...rest] = [1, 2, 3, 4]; console.log(first); // outputs 1 console.log(rest); // outputs [ 2, 3, 4 ]   当然,由于是JavaScript, 你可以忽略你不关心的尾随元素: let [first]

sudo go 找不到命令

泪湿孤枕 提交于 2019-12-03 14:35:24
我们使用 sudo 时,使用的配置文件是 /etc/sudoers。 解决 配置 /etc/sudoers 文件中的 Defaults secure_path 这一项。将 $GOROOT/bin 目录加入进去。(请使用绝对目录,如:/home/go/bin/) Defaults secure_path 这一行,在文件中是这样子的: Defaults secure_path = /home/go/bin:/sbin:/bin:/usr/sbin:/usr/bin 其他问题 当我们使用了自己 GOPATH 中的包时,sudo go run xxxx 并不会在我们环境变量指定的目录去查找包。 我们需要设置 /etc/sudoers 文件中的 Defaults env_keep 项。向其中加入我们的 GOPATH 环境变量。 Defaults env_keep 这几行,在文件中是这样的: Defaults env_keep = “COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS” Defaults env_keep += “MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE” Defaults env_keep += “LC_COLLATE LC_IDENTIFICATION LC

ES6-对象的扩展-Object.assign()

柔情痞子 提交于 2019-12-03 12:40:47
基本用法 Object.assign 方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象(target)。 const target = { a: 1 }; const source1 = { b: 2 }; const source2 = { c: 3 }; Object.assign(target, source1, source2); target // {a:1, b:2, c:3} Object.assign 方法的第一个参数的目标对象,后面的参数都是源对象。 注意,如果目标对象与源对象有同名属性,或多个源对象有同名属性,则后面的属性会覆盖前面的属性。 const target = { a: 1, b: 1 }; const source1 = { b: 2, c: 2 }; const source2 = { c: 3 }; Object.assign(target, source1, source2); target // {a:1, b:2, c:3} 如果只有一个参数,Object.assign 会直接返回参数。 const obj = {a: 1}; Object.assign(obj) === obj // true 如果该参数不是对象,则会先转成对象,然后返回。 typeof Object.assign(2) // "object"

anaconda/conda - install a specific package version

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to install the 'rope' package in my current active environment using conda. Currently, the following 'rope' versions are available: (data_downloader)user@user-ThinkPad ~/code/data_downloader $ conda search rope Using Anaconda Cloud api site https://api.anaconda.org Fetching package metadata: .... cached-property 1.2.0 py27_0 defaults 1.2.0 py34_0 defaults 1.2.0 py35_0 defaults 1.3.0 py27_0 defaults 1.3.0 py34_0 defaults 1.3.0 py35_0 defaults rope 0.9.4 py26_0 defaults 0.9.4 py27_0 defaults 0.9.4 py33_0 defaults 0.9.4 py34_0 defaults 0

Problems with fbDidLogin never called iOS

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having problems with my app saving the access_token. The problem is, when an iPhone hasn't the Facebook app installed, safari will handle this and there is no problem. But as soon as the iPhone has the Facebook app installed. It Just isn't saving the access token and opens the Facebook app every time when it needs to do something with Facebook. It then says, you already have given .... permission... This is what i'm doing to in the viewdidload to ask permission the first time and receive the access token from the user defaults: facebook

Thread 1: Stopped at breakpoint 1

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a problem with XCode 4.3.2, and I cannot figure out what it is. I have set a breakpoint, but instead that XCode stops at the line the breakpoint is set, it shows me the thread log. I am going crazy here. So, this is the page I see in XCode when it comes to my breakpoint. It does this is several projects and tried it both with and without zombie enabled. 回答1: I searched google for resetting XCode, and it seems that this post helped me out: http://www.developers-life.com/uninstallresetting-xcode.html However, I did this in the

how to remove the controller name from the url using rout in MVC [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: This question already has an answer here: ASP.NET MVC - Removing controller name from URL 5 answers How to remove the controller name from the URL in MVC 5. I tried to add the route in the route.config public class RouteConfig { public static void RegisterRoutes ( RouteCollection routes ) { routes . IgnoreRoute ( "{resource}.axd/{*pathInfo}" ); routes . MapMvcAttributeRoutes (); routes . MapRoute ( name : "Default" , url : "{controller}/{action}/{id}" , defaults : new { controller = "Home" , action = "Index" , id = UrlParameter .

NHibernate *.hbm.xml 文档

匿名 (未验证) 提交于 2019-12-03 00:41:02
# class <class name="ClassName" (1) table="tableName" (2) discriminator-value="discriminator_value" (3) mutable="true|false" (4) schema="owner" (5) proxy="ProxyInterface" (6) dynamic-update="true|false" (7) dynamic-insert="true|false" (8) select-before-update="true|false" (9) polymorphism="implicit|explicit" (10) where="arbitrary sql where condition" (11) persister="PersisterClass" (12) batch-size="N" (13) optimistic-lock="none|version|dirty|all" (14) lazy="true|false" (15) abstract="true|false" (16) /> (1) name: The fully qualified .NET class name of the persistent class (or interface),