Posts

angularjs - Utility functions for directives -

say want make angular directive generates links resources this: <a href="http://link/to/resource/1234">link/to/resource/1234</a> from object looks like: resource = { id: 1234, otherproperty: 'foo' } how can w/ directive? ie, i'd not have repeat part goes '/link/to/resource/{{id}}' . can't seem work right. 1 of several things i've tried: app.directive('myresource', function() { return { restrict: 'e', scope: { resource: '=' }, baseurl: 'link/to/{{resource.id}}', template: '<a href="http://{{baseurl}}">{{baseurl}}</a>' }; }); which ends rendering: <a href="http://" class="ng-binding"></a> other things i've tried (like making baseurl function/sticking in scope ) have resulted in similar things/errors. is there way work? one way handle use directive's link function set variab...

c# - Using Forms Auth. with Claims Based Auth -

using this guide i've implemented claims based auth on asp.net webforms successfully. problem while using claims based auth. cannot use forms based auth in same app pool: <authorization> <deny users="?" /> </authorization> <authentication mode="none" /> is there way use both?

python - abort method in Flask-Restful ignoring CORS options -

i have flask-restful api configured cors options: api = api() api.decorators=[cors.crossdomain(origin='*', headers=['accept', 'content-type'])] ... api.init_app(app) my api accepts post requests may fail if data in request invalid: class myapi(resource): def post(self): args = request.get_json() if args.get('something'): return {'message': 'request worked, data received!', 'something': args['something']} else: abort(500, "error: data must contain 'something' field!") when make successful post request api can see cors options set: ... * upload sent off: 81 out of 81 bytes * http 1.0, assume close after body < http/1.0 200 ok < content-type: application/json < content-length: 205 < access-control-allow-origin: * < access-control-allow-methods: head, get, post, options < access-control-max-age: 21600 ...

html - CSS - Overflow and Positioning -

i saw similar post dealing issue, problem wee bit different. in issue outlined here , concept outer div positioned relative, , inner div positioned absolute, , overflow:hidden preserved. my issue both divs, inner , outer positioned absolute. how can still preserve overflow: hidden on outer div? not sure of question, try achieve? see jsfiddle css: #outer { position: absolute; top: 10px; left: 10px; height: 80px; width: 50px; overflow: hidden; } #inner { position: absolute; top: 10px; left: 10px; height: 50px; width: 50px; } with html: <div id='outer'> <div id='inner'> // stuff here </div> </div>

assembly - Most efficient/idiomatic way to test a 256-bit YMM AVX register for zero -

i have x86_64 routine ends 0 in ymm register if successful, , i'd return non-zero if ymm register. i have way clearing ymm register, vptest'ing register against one, , conditionally incrementing resturn register (rax in case) if cf not set: " xor %%rax, %%rax \n" // clear rax " vxorpd %%ymm0, %%ymm0, %%ymm0 \n" // clear ymm0 " vptest %%ymm1, %%ymm0 \n" // compare ymm1 0 " jc endcheck \n" // branch on if no residue " inc %%rax \n" // inc rax otherwise "endcheck: \n" // result in rax this seems opaque way it. there better way, or more idiomatic or readable way? combining comments above, can done in 3 lines of assembly: "xor %%rax, %%rax \n" // clear rax "vptest %%ymm1, %%ymm1 \n" // if ymm1 zero, set zf "setnz %%al...

database - Postgresql : Loop thorugh each table and check for column? -

i trying write simple sql query in pgadmin loop through each table in database , change specified column name if exists. have never coded in sql after searching through many forums have managed come with: do begin in select table_name information_schema.tables loop if select column_name information_schema.columns table_name = 'i.table_name' alter table i.table_name rename column old_column_name new_column_name end if; end loop; any great. you can skip information_schema.tables entirely. just: do $$ declare rec record; begin rec in select table_schema, table_name, column_name information_schema.columns column_name = 'x' loop execute format('alter table %i.%i rename column %i newname;', rec.table_schema, rec.table_name, rec.column_name); end loop; end; $$ language plpgsql; with appropriate substitutions 'x' , newname . or make function takes them parameters, what...

How do you access params[:model][:field] in Rails 4? -

from understand... if have form_for @model , params[:model] available when form submitted. furthermore, if form has 2 attributes attr1 , attr2 , params[:model][:attr1] , params[:model][:attr2] available when form submitted. in rails 4, you're supposed write method model_params says params.require(:model).permit(:attr1, :attr2) . you'd use model_params so: model.new(model_params) . however, do if need 1 of fields form? if needed params[:model][:attr1] ? example: def create @user = user.new(user_params) if @user.save # need access params[:user][:password] here redirect_to root_url, :notice => "signed up!" else render :new end end private def user_params params.require(:user).permit(:email, :password, :password_confirmation) end the gem responsible behaviour strong_parameters . permit() method decides pass on model based on attributes pass it. in case, passed :attr1 , :attr2 : params.require(:m...