Posts

Search and extract results from an array based on an entry keyword in ruby -

i compare array element , extract data in array here example of data i'm working with: array = [{:id=>3, :keyword=>"happy", :date=>"01/02/2016"}, {:id=>4, :keyword=>"happy", :date=>"01/02/2016"} ... ] for example want first keyword happy search same array ,extract if there's similar words , put them inside array here i'm looking end result: results = [{:keyword=>happy, :match =>{ {:id=>3, :keyword=>"happy", :date=>"01/02/2016"}... }] here first part of code : def relationship(file) data = open_data(file) parsed = json.parse(data) keywords = [] = 0 parsed.each |word| keywords << { id: += 1 , keyword: word['keyword'].downcase, date: word['date'] } end end def search_keyword(keyword) hash = [ {:id=>1, :keyword=>"happy", :date=>"01/02/2015"},...

python - Django doesn't load static files from S3 -

i made run 'python manage.py collectstatic' upload staticfiles s3 bucket. but after running 'sudo service apache2 restart', page doesn't load staticfiles although s3 bucket has 'static' directory including static files. how can solve problem? i include static files below : {% load compress %} {% load static staticfiles %} {% compress css %} <link rel="stylesheet type="text/css" href ="{% static 'bower_components/.../bootstrap.css' % /} ... {% endcompress %} my settings.py below: static_url = s3_url + '/static/' # path of static directory included in s3 bucket static_root = static_url staticfiles_dirs = ( os.path.join(base_dir, 'static/'), ) is there i'm missing now?

angular - ionic 2 - item slider - slide to trigger function -

i have ionic-item-sliding directives 3 buttons. 2 (a , b) appear when slide left , 1 (button c) on right. i want implement behavior function under button c triggered when drag item far right. the docs on ionic2 hompage give code snippet example ondrag(event, item) { let percent = event.getslidingpercent(); if (percent > 0) { // positive console.log('right side'); } else { // negative console.log('left side'); } if (math.abs(percent) > 1) { this.navctrl.push(nextpage,{param:item},{ animate: true, direction: 'forward' }) } } using on <ion-item-sliding *ngfor="let item of items "(iondrag)="ondrag($event, item)"></ion-item-sliding> i've getting behaviour when swipe far, call , push page multiple times (i guess many events i'm throwing) any suggestions on how implement correctly? thanks! you add flag sure push() method executed once. import { component } ...

android - How to prevent custom dialog from blinking cursor on first EditText inside of it -

i creating custom dialog window problem when dialog first launches automatically begins flashing cursor on first edittext in linearlayout defines structure of dialog. keyboard not appear, first edittext has blinking cursor on it. i attempted use requestfocus() function on textview within dialog cannot edited, blinking cursor remains on first edittext in dialog. if has advice or solutions solving problem, great. use either xml attribute or java function- xml: android:cursorvisible="false" java function: setcursorvisible(false)

Python custom 404 response error -

Image
i wrote hiscore checker game play, enter list of usernames .txt file & outputs results in found.txt. however if page responds 404 throws error instead of returning output " 0 " & continuing list. example of script, #!/usr/bin/python import urllib2 def get_total(username): try: req = urllib2.request('http://services.runescape.com/m=hiscore/index_lite.ws?player=' + username) res = urllib2.urlopen(req).read() parts = res.split(',') return parts[1] except urllib2.httperror, e: if e.code == 404: return "0" except: return "err" filename = "check.txt" accs = [] handler = open(filename) entry in handler.read().split('\n'): if "no displayname" not in entry: accs.append(entry) handler.close() account in accs: display_name = account.split(':')[len(account.split(':')) - 1] total = get_total(display_name) if "err" not in total: rstr = account + ' -...

java - use rest api written for angular js in android app -

i need know if write rest api in java using spring framework , using in angular js front end, possible use same api's andriod app later. use same api's both web , app, have no idea android development, please help. if api restful, , mean @ least stateless , resource based. yeah, doesn't matter program you're requesting data from. if able process response front end (reading format, etc). it'll fine. make sure api's endpoints work correctly , configured handle request programs using communicate api (most of times these http requests)

php - Hiding font names on a text/font previewer -

i coding online store customers able customise products text choosing few hand picked fonts. want use text/font preview box on website below: https://www.myfonts.com/fonts/cbx-jukebox/corner-store-jf/ creating font preview my question is, if create text/font previewer website possible mask true name of font using or still able find out looking code somehow or addon font? i thought give font files different names wasn't sure if work? i looked using cufon understanding download font file js. the reason because have gone lot of time select unique stylish fonts , don't want make easy competitors copy designs being able find out font is you cannot client side code (css, js). how hide when possibility there. maybe can done server-side code php gd. however, tiring work.