Wednesday, May 31, 2017

Most efficient way to search for unknown patterns in a string?

Leave a Comment
I am trying to find patterns that: occur more than once are more than 1 character long are not substrings of any other known pattern without knowing any of the patterns that might occur. For example: The string "the boy fell by the bell" would return 'ell', 'the b', 'y '. The string "the boy fell by the bell, the boy fell by the bell" would return 'the boy fell by the bell'. Using double for-loops, it can be brute forced very inefficiently: ArrayList<String> patternsList = new ArrayList<>(); int length...
Read More

Get Google Drive video stream in json

Leave a Comment
I know this question has been answered a lot, I have a script that get the download links for a google drive video, it works well but the links are not working. I've seen an app that has this function working and the output of it is: https://redirector.googlevideo.com/videoplayback?api=GameLife&id=a4f79817c6ef67f8&itag=59&source=webdrive&requiressl=yes&ttl=transient&mm=30&mn=sn-n4v7kne7&ms=nxu&mv=u&pl=33&sc=yes&ei=sR8jWbqLHoGbqwX595ioDw&driveid=0B4sZ0D2_HqvbSjJWLW8wZTRXN00&mime=video/mp4&lmt=1486066497769085&mt=1495473955&ip=2600:3c01::f03c:91ff:fe1f:fc40&ipbits=0&expire=1495488497&sparams=ip,ipbits,expire,id,itag,source,requiressl,ttl,mm,mn,ms,mv,pl,sc,ei,driveid,mime,lmt&signature=8AFB0862FB9AB02C64544F9F462D7040303A1E04.80FD021C0481D93E50E842705E9B97F11617954A&key=ck2&??/Gemo.mp4...
Read More

XCode: Embed Framework in React Native Module without modifying application project

Leave a Comment
I am developing a React Native Module that includes our Framework 'AntaviSense'. I am able to include the framework in the main project and by "embed framework" in the Project Settings, everything works fine. React Native Module Adding to main project works My question though is: can I avoid changing the main project, and just include it into the React Native Module project (which is a subproject)? I tried various directories in "React-Module/Build Phases/Copy Files" without luck. This would make the inclusion into other...
Read More

Node.js app deploy in heroku

Leave a Comment
I have the following file structure of my MEAN app: root |---> public |----> css |----> js |----> controller |----> app.js |----> views |----> index.html |---> app |----> server.js |---> node_modules |---> bower_components |---> gulpfile.js |---> package.json |---> Procfile In this app, I run public/index.html using gulp, gulpfile.js: var gulp = require('gulp'); var browserSync = require('browser-sync'); var server...
Read More

Exporting all anchor tag references to formatted CSV file from Chrome dev console

Leave a Comment
Let us assume we have a webpage which displays contacts from one person's social network , with a contact name anchored to an href , which points to a unique URL for the user's profile . I scroll down to the bottom of the page and can see several hundred contacts . Is it possible for me to export all href occurrences to a csv file with this structure from the developer console via JS ? Col1 : Name Col2 : profile-url The end result...
Read More

Android textview text get cut off on the sides with custom font

Leave a Comment
This is what happens in the preview and on device: TextView is nothing special, it just loads the custom font: public class TestTextView extends AppCompatTextView { public TestTextView(Context context) { super(context); init(context); } public TestTextView(Context context, AttributeSet attrs) { super(context, attrs); init(context); } public TestTextView(Context context, AttributeSet...
Read More

How to create the strings sequence into specified line in edited text?

Leave a Comment
Here is the initial text. test1 test2 Only two lines in the text. I want to insert strings sequence into from 5th line into 16th line. I have tried it with below codes. for i in range(1,12) echo ".item".i."," endfor 1.the initial text. 2.to enter into command mode and input the codes Two problems to be solved. 1.echo command output the first string .item1 before endfor. for i in range(1,12) echo ".item".i.","...
Read More

execinfo.h missing when installing xgboost in Cygwin

Leave a Comment
I've follow the following tutorial in order to install xgboost python package within Cygwin64: https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_For_Anaconda_on_Windows But when executing the make in dmlc-core directory I get the following errors: harrison4@mypc ~/xgboost/dmlc-core $ mingw32-make -j4 g++ -c -O3 -Wall -Wno-unknown-pragmas -Iinclude -std=c++0x -fPIC -DDMLC_USE_HDFS=0 -DDMLC_USE_S3=0 -DDMLC_USE_AZURE=0 -msse2 -o line_split.o src/io/line_split.cc g++ -c -O3 -Wall -Wno-unknown-pragmas...
Read More

Tuesday, May 30, 2017

How to create a wrapper function for default knockout bindings

Leave a Comment
I am displaying a huge tabular structure with knockout. The user has the option to remove rows by clicking a checkbox on the row: data-bind="checked: row.removed" The problem is that the table has to be re-rendered on click, which on slow computers/browsers takes up to one or two seconds - the checkbox changes its state after the table has been rendered so the UI feels unresponsive. I would like to create a wrapper function that does the same thing as the default checked-binding but additionally displays a loader symbol...
Read More

How can open google map in iOS using Meteor

Leave a Comment
I need to open google map app on iOS using Meteor js. I could do it in Andriod using window.open("geo:" + addressLongLat, "_system");, but the same code not working iOS. 4 AnswersAnswers 1 On iOS geo: url scheme doesn't open Google maps, it can open Google Earth Google maps app allows this three url schemes, comgooglemaps://, comgooglemaps-x-callback:// and comgooglemapsurl:// More information about google maps url schemes You can also use the http url, that will open the app if it's installed or a website if it...
Read More

Proper packaging of runnable Jar project in netbeans

Leave a Comment
So my task is to create a small program that displays a list of media files and run these media files with default OS media player separately. My current solution was to create a package that holds all media files, something like: -com.media |_a.mp4 |_b.mp4 The following code copies to a temp dir the selected mp4, then runs the default os media player: public File copyTempMedia(File tempAppFolder, String videoName) { URL f = getClass().getResource(String.format("%s/%s", Constants.MEDIA_LOCATION,...
Read More

How to test ActiveJob retries

Leave a Comment
I have this job ia Rails 5.1 app. Don't mind retries_count (that is defined inside the CountRetries concern). The idea is that the job is retried 5 times if a CustomError is raised, with 10 minutes between retries. class MyOwnJob < ApplicationJob include CountRetries queue_as :default def perform(argument) begin # Do some stuff rescue CustomError if retries_count < 5 retry_job wait: 10.minutes else logger.error "Job retries exhausted" end end end end The...
Read More

Process.Start() exits right away on Windows 7

Leave a Comment
Process.Start("d:/test.txt"); //simple .txt file works perfectly fine on Windows 8 onward but on Windows 7 (x64) it starts the process and immediately closes it. I've already tried the following: Calling through ProcessStartInfo and setting CreateNoWindow=true, UseShellExecute=true and Verb="runas" (though not sure why I had to set this one). Tried attaching Exit event and it confirms that the process does start but it exits right away and I don't even see the Notepad window open for a blink of a second. Edit: I've...
Read More

Deploying libgdx to html

Leave a Comment
I tried deploying Libgdx to html using gradle. I copied the content html/build/dist and all I see in the browser is the badlogic image with a red background (what you would see if you just created a project) Why is that? Using the superdev I can open it in the browser, i see where it says drag this button but can't play it. there's nothing The code server is ready at http://127.0.0.1:9876/ GET /clean/html Cleaning disk caches....
Read More

I'm uploading data from my Swift app to Amazon S3 and it drains battery like nothing else. How can this be avoided?

Leave a Comment
In my 'Swift' app I have a feature of uploading photos to my Amazon S3 bucket. When the user is connected to WiFi or LTE, there's no problem, but when the connection is a little slower (e.g. 3G), then the upload takes a lot of time (up to one minute) and iphone can lose 15-20% of battery! I resize photos down to around 200-300kb, so that should not be a problem. The code that I use for that is: func awsS3PhotoUploader(_ ext: String, pathToFile: String, contentType: String, automaticUpload: Bool){ let credentialsProvider...
Read More

PHP Nested JSON from flat JSON

Leave a Comment
I have a database query that provides me the output of some employee data. I want to use this data to pass to a plugin that generates an org chart. There are a few fields in the JSON object that I am pulling down which are: FirstName LastName EmployeeID ManagerEmployeeID Manager Name The data is returned as flat JSON object with no nesting or corellation between employees and their managers in the hierarchy. Since I am unable to change the output of the source data (the database query), I am trying to figure out a...
Read More

Certificate pinning in Xcode

Leave a Comment
I got below code for certificate pinning in Android CertificatePinner certificatePinner = new CertificatePinner.Builder() .add("publicobject.com", "sha1/DmxUShsZuNiqPQsX2Oi9uv2sCnw=") .add("publicobject.com", "sha1/SXxoaOSEzPC6BgGmxAt/EAcsajw=") .add("publicobject.com", "sha1/blhOM3W9V/bVQhsWAcLYwPU6n24=") .add("publicobject.com", "sha1/T5x9IXmcrQ7YuQxXnxoCmeeQ84c=") .build(); How do i achieve same task in IOS using NSURLSession method? Got some reference code here - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge...
Read More

can we override Apache CXF generated HTML page

Leave a Comment
can we override Apache CXF generated HTML page i tried <init-param> <param-name>hide-service-list-page</param-name> <param-value>true</param-value> </init-param> but it shows "No service was found" instead of showing this how can we show different html page. Thanks 1 AnswersAnswers 1 Apache cxf use a class called FormattedServiceListWriter to generate the html page that you are talking about, you can take a look of the code here. What...
Read More

How to configure/Enable the form based authentication in SSRS 2008 RS

Leave a Comment
I have two reports , one is for internal users and another one is for external users, For internal Users i need to enable form authentication to view the report instead of creating the user accounts in the server. For external User i do not want to enable any authentication, so that they can access the report from the browser without any authentication. I followed the below steps by using the SSRS samples from the below link, after did all the changes i am getting HTTP500 Error. please help to enable this form based...
Read More

Monday, May 29, 2017

Scrolling gets “stuck” when using nested scroll views

Leave a Comment
Problem description: I have one iOS project for browsing images with nested UIScrollViews which is inspired by famous Apple's PhotoScroller. The problem is what sometimes scrolling just "stuck" when image is zoomed width- or height-wise. Here is an example of how it looks on iPhone 4s for image of size 935x1400 zoomed height-wise: (I start dragging to left, but scroll view immediatly discard this action and image get "stuck") ...
Read More