Posts

ios - How do I make a swift file with prewritten suggested methods? -

i've made new swift file named "customsearchbar" inherits uisearchbar, import uikit class customsearchbar : uisearchbar { } my question is, how fill .swift file nice, pre-made suggested functions apple's included comments , such. i've seen done before can't quite remember. thanks help. when add new file choose cocoa touch class not swift file . there, can choose new file subclass of uisearchbar . xcode generate nice suggested functions , comment you.

TeamCity error after addind SVN subrepo to Mercurial -

i added svn project subrepository mercurial project (following this instructions) , teamcity cannot build mercurial project. following error: [updating sources] failed build patch build #???, vcs root: "mercurial: https://myrepo" {instance id=41, parent internal id=22, parent id=mercurial_repo_id, description: "mercurial: https://myrepo"}, due error: cannot build patch: clientabortexception: java.io.ioexception [updating sources] problem while loading patch data stream: failed obtain stream server. server status: 504 (gateway time-out) problem while loading patch data stream: failed obtain stream server. server status: 504 (gateway time-out) java.io.ioexception: failed obtain stream server. server status: 504 (gateway time-out) when clone repo locally, goes fine, teamcity doesn't see subrepo , there no subrepo in changes graph. tried add different build steps, didn't help. tried change vcs checkout mode in teamcity agent-checkout, there error du...

html - Javascript image changer: MDN Javascript basics -

Image
i'm going through web development guide on mozilla developer network, , in js basics section , came across example: var myimage = document.queryselector('img'); myimage.onclick = function() { var mysrc = myimage.getattribute('src'); if(mysrc === 'images/firefox-icon.png') { myimage.setattribute ('src','images/firefox2.png'); } else { myimage.setattribute ('src','images/firefox-icon.png'); } } when worked out example, although did execute expected, have question image path. here's file structure: my question is: when working images in html, if present .html file in folder called pages , along side other sibling folders images , scripts , etc, file structure have followed in case reach image so: ../images/filename.jpg . .. used reach main(root) folder pages folder, access images folder there. how image changer example work then, without .. being used? file here main.js in sub-f...

Youtube Data API v3: commentThread call doesn't give replies for some comment threads -

Image
i have problem commentthread api call. here 1 specific case: comment id: z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k https://www.googleapis.com/youtube/v3/commentthreads?id=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&part=snippet%2c+replies&key= {your_developer_key}&alt=json&order=time there 44 replies now. but if use video_id (not comment id did above. link: https://www.googleapis.com/youtube/v3/commentthreads?videoid=ui-ulcwmpou&maxresults=100&pagetoken=chyqp7fipbfsxgiykngqiobjxqigacgdehqiabcq0aqkhupfahimqqkive-5ahgcikwc&part=snippet%2c+replies&key= {your_developer_key}&alt=json&order=time) , come across comment (you may have use pagetoken iterate on pages) see this: (screenshot: https://www.dropbox.com/s/d4bf9tk51eaw7dr/screenshot%202015-07-21%2021.08.31.png?dl=0 ) as noticed; there 39 replies (comments) not true. , if have replies; there no replies section. missing something? two questions: why number of replies don't match? why com...

Split string that looks like a Python function call to arguments -

i trying make function accepts string looks function call in python , returns arguments function example: "fun(1, bar(x+17, 1), arr = 's,y')" will result: ["1", "bar(x+17, 1)", "arr = 's,y'"] the problem of using regular expressions don't know if possible not split @ commas inside parenthesis or quotes. thanks. edit: python: splitting function , arguments doesn't answer correctly quastions since doesn't treat commas in parenthesis or quotes. as @kevin said, regular expressions cannot solve this since can't handle nested parenthesis. you can keep track of own state def parse_arguments(s): openers = "{[\"'(" closers = "}]\"')" state = [] current = "" c in s: if c == "," , not state: yield current current = "" else: current += c if c in openers...

arrays - Split a string while keeping delimiters Haskell -

basically i'm trying split string [[string]] , concat results keeping delimiters in resultant list (even repeating in row). something below kind of works, delimiter gets crunched 1 space instead of retaining 3 spaces unwords . map (\x -> "|" ++ x ++"|") . words $ "foo bar" -- "|foo| |bar|" ideally like: "|foo|| ||bar|" -- or "|foo| |bar|" i can't figure out how preserve delimiter, split functions i've seen have dropped delimiters resulting lists, can write 1 myself seems in standardish library , @ point i'm looking learn more basics includes getting familiar more colloquial ways of doing things. i think i'm looking function like: splitwithdelim :: char -> string -> [string] splitwithdelim "foo bar" -- ["foo", " ", " ", " ", "bar"] or maybe it's best use regexes here? you can split list, keeping de...

javascript - Inject service/object into controller after an asynchronous (ajax) call -

i globalizing website developed both asp.net mvc , angularjs. js part using angular-localization load resource bundles. right have controller this: app.controller('mycontroller', ['$scope', function($scope) { $scope.msg = "hello world!"; }]); with nglocalize can use locale service, getting resource string in callback: app.controller('mycontroller', ['$scope', 'locale', function($scope, locale) { locale.ready('resourcefile').then(function() { $scope.msg = locale.getstring('resourcefile.helloworld'); }); }]); the problem have translate hundreds of strings , introducing callback makes hard review code, , forces me change controller logic (e.g: when need resource string inside function return message caller). call locale.getstring() directly, without callback: app.controller('mycontroller', ['$scope', 'locale', function($scope, locale) { $scope.msg = locale.getstring(...