Nikolay Dyankov

0

votes
2

answer
26

views

What does { …obj1, obj2 } do exactly

Let's say we have two objects: const state = { fishes: { /* some obj data }, animals: { /* some obj data } const animals = { /* some NEW data } In Vuex there is a method replaceState(), which according to the documentation takes one argument and replaces the state with that object. What will be the...
Nikolay Dyankov
1

votes
1

answer
1.9k

views

Making a blur algorithm work with canvas image data?

I have the following simple blur algorithm: for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { total = 0 for (ky = -radius; ky
Nikolay Dyankov
1

votes
1

answer
138

views

Objective C Regex?

I'm trying to parse a 7-digit number from a page's source code and the pattern that I look for is /nnnnnnn' where 'n' is a digit. I'm trying with the following regex and in a regex test site it works, but not in obj-c. Is it possible that I'm passing the wrong option or something? NSRegularExpressi...
Nikolay Dyankov
1

votes
3

answer
315

views

Fetch a POST request that a site is sending to itself?

So I'm creating an app for a specific website, which has comments on certain articles/entities or whatever. I already know how to fetch those comments with RSS, but I'm also curious if I can implement a reply functionality from the app itself. The site doesn't have an API for that, but I know that w...
Nikolay Dyankov
1

votes
1

answer
729

views

Quickest way to traverse an XML document with Node.js?

From a similar question I found out about XPath and it looks incredibly fast, but I can't use it with Node.js: > var xp = new XPathEvaluator(); ReferenceError: XPathEvaluator is not defined at repl:1:14 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at REPLServer.self.eval (repl.js:122:7...
Nikolay Dyankov
1

votes
1

answer
1.2k

views

How exactly to implement challenge-response for REST API authentication?

I want my REST API server to be able to communicate only with my iOS app. The user base is going to be no more than 1000 people, and the market is pretty small and unpopular in general. That's why I think anything beyond a simple challenge-response authentication (HTTP, OAuth 2.0, SSL) would be an o...
Nikolay Dyankov
1

votes
1

answer
115

views

CSS media queries issue with visualizing the right image size and margin

I am trying to add margin and reduce an image size based on the detect size of the screen using CSS media queries. However for one or another reason which I can not figure out the code is not working. What is not working: When you switch to mobile it is not adding the margins and it is not reducing...
Nikolay Dyankov
1

votes
2

answer
149

views

“Incomplete Headers” with PHP's mail() function

[Sat Apr 25 04:18:46.660552 2015] [fastcgi:error] [pid 11271:tid 140464355243776] [client 95.87.236.146:63037] FastCGI: comm with server '/usr/lib/cgi-bin/php5-fcgi-domain.cc' aborted: idle timeout (30 sec), referer: http://domain.cc/login/restore_session.php?redirect=yes [Sat Apr 25 04:18:46.660673...
Nikolay Dyankov
1

votes
1

answer
47

views

change of value on selections

I have a slider containing of two images. I have split them into two classes : item active and item. i also have a dropdown selection box where I can select the color. Depending on the selection I would like to show the selected color. The first class: The second class: DropDown Menu Selection1 Sele...
Nikolay Dyankov
1

votes
2

answer
524

views

.htaccess file returns 404 for subfolders

I have the following htaccess on my site, which is supposed to redirect to https:// and rewrite URLs like this: http://company.com/product.php Becomes this: https://company.com/product/ Here is the current code: ErrorDocument 404 /404.php RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) ht...
Nikolay Dyankov
1

votes
1

answer
0

views

Is it possible to determinate if an element is currently overflowing its container?

I want to check if a horizontal scrollbar is applied to a div like this: if (box.width() < box.get(0).scrollWidth) This is always true, even when there isn't any scrollbar, because box.get(0).scrollWidth returns 203px, while .width() returns 200. Here I have an example, please look at the first box....
Nikolay Dyankov
1

votes
4

answer
0

views

How can I reference a non-global function with window[functionName]?

I'm making something like a framework for JS. I want the users to be able to add functions to a specific action, just like in wordpress plugins: add_action('wp_head', 'functionName'); I looked at other questions, and the most appreciated answer was window['functionName'] But how do I do it when the...
Nikolay Dyankov
1

votes
1

answer
121

views

iOS Core Data - how to request entities for each object in an array?

Don't know if you got my question, so here is an example. I have an array with 50 product IDs and I want to check if all IDs exist in Core Data. How would I do that without a loop and making 50 requests? There must be a more efficient way than that I think. In my model I have an entity Product with...
Nikolay Dyankov
1

votes
1

answer
1.2k

views

Recursively subtract two JavaScript objects

Let's have an object with some default settings: var defaults = { id: '', x: 0, y: 0, width: 20, height: 20, styles: { color: '#ffffff', background_color: '#000000' }, points: [] } Then, we make our own object, which initially extends the default settings, and makes some changes: var newObject = { i...
Nikolay Dyankov
1

votes
2

answer
483

views

Confirmation before running a Grunt task

I have a task in Gruntfile.js which can potentially wipe my project and I want to protect it with a 'Are you sure you want to run this task?' question before running it, just to be safe. Something like: grunt.registerTask('install', 'Run this only once when starting a project!', function() { console...
Nikolay Dyankov
1

votes
2

answer
45

views

.htaccess ignore requests for css/js/images?

I'm currently running this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.html RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1...
Nikolay Dyankov
18

votes
4

answer
11.5k

views

CSS Animations - change a property without a transition?

I have a case where I need an element to appear for a second and then disappear, and I must not use javascript for it, so I'm trying to make it work with CSS. Here's an example: @-webkit-keyframes slide-one-pager { 0% { left: 0; } 50% { left: 100px; } 100% { left: 0; } } So in this example the prope...
Nikolay Dyankov
5

votes
1

answer
11.7k

views

Node.js - server closed the connection?

I'm running a web app on a Node.js server and I need it to be online all the time, so I'm using forever. But here is what I'm getting after a period of time: Error: Connection lost: The server closed the connection. at Protocol.end (/home/me/private/app/node_modules/mysql/lib/protocol/Protocol.js:73...
Nikolay Dyankov
11

votes
2

answer
8.8k

views

Canvas: mask an image and preserve its alpha channel?

Here's what I'm trying to do: Get image A, and image B. Image B is a black and white mask image. Replace image A's alpha channel with image B's red channel. Draw image C on the canvas. Draw image A on top of image C. Everything seems ok until step 4. Image C isn't visible at all and where image A sh...
Nikolay Dyankov
3

votes
1

answer
1.7k

views

Install Firefox Addon from a link, instead of downloading the .xpi

I just made a FF addon and made a simple website. I'd like when a visitor clicks the 'download' button the addon to install, instead of getting downloaded. It works locally, but not when I upload the site. I checked the mozilla repository, they just link to the xpi file as well. What am I doing wro...
Nikolay Dyankov
4

votes
2

answer
2.6k

views

Cross-browser solution for a callback when loading multiple images?

I checked other questions, but they all had information how to make a callback when one specific image has loaded: var img = new Image(); img.src = 'images/img.png'; if (!img.complete) { img.onload = function() { // code to be executed when the image loads } } Or a simple check to see if all images...
Nikolay Dyankov
2

votes
4

answer
6.8k

views

Bootstrap - btn-group, data-toggle=“buttons” : how to select a button with JS and deselect all others?

Hi, I'm using Bootstrap's .btn-group class like this: button-1 button-2 button-3 button-4 In my app I need to 'manually' select a button with JS and currently I'm doing it like this: $('#radio-popup-style-rect-1').parent().addClass('active'); $('#radio-popup-style-rect-1').get(0).checked = true; $('...
Nikolay Dyankov
2

votes
1

answer
4.3k

views

How to make IE8 respect .removeClass()?

The code that's giving me headaches is this: $('#timeline .selected').removeClass('selected'); It just won't behave properly in IE8. The classes DO get removed properly, but somehow the element still has the same styling, just as the style with the class 'selected'. P.S. Those two won't work either:...
Nikolay Dyankov
7

votes
2

answer
2.7k

views

NSArray containsObject: faster alternative?

I did some runs on my iOS app with Instruments and I saw that 90% of the load on the main thread on launch (about 1000ms total) is caused by containsObject: calls. That's on the main thread and I don't think it's cool. Is there a faster alternative to this method? An algorithm or another method? Any...
Nikolay Dyankov
3

votes
1

answer
57

views

Many rectangles in a container - when changing the size of one of them, others must compensate

Let's consider the following example: http://jsfiddle.net/m0gxgu21/ // See the full commented code and a visual example in the JSFiddle var rects = [ { x: 0, y: 0, w: 120, h: 120 }, { x: 120, y: 0, w: 100, h: 40 }, { x: 220, y: 0, w: 100, h: 120 }, { x: 120, y: 40, w: 100, h: 80 }, { x: 0, y: 120, w...
Nikolay Dyankov
2

votes
2

answer
890

views

Canvas globalAlpha doesn't affect images?

I'm trying to put series of images on the canvas with putImageData(), but the globalAlpha property of the context doesn't seem to have an effect. However, it's working with drawImage(). Is that how it's supposed to work? That snippet doesn't work: cx.globalAlpha = 0.1; cx.putImageData(imagesData[ind...
Nikolay Dyankov
2

votes
1

answer
3k

views

How to install “pthreads” on OSX, PHP 5.5.30

I couldn't find any step-by-step guide how to install this thing on OSX. And I don't want to recompile PHP, if that's possible. Is there simply a package that I can install from somewhere that will just enable pthreads? I tried with: pecl install pthreads pecl/pthreads requires PHP (version >= 7.0.0...
Nikolay Dyankov
5

votes
1

answer
3.6k

views

Facebook notifications - need permission or not?

Here is what I'm seeing in the docs: Apps can send notifications to any existing user that has authorized the app. No special or extended permission is required. Okay, sounds good. I'm using the JS SDK and here is what I'm trying to do: FB.api('/me/notifications?access_token=' + window.accessToken +...
36

votes
3

answer
55.2k

views

How do I clear all intervals?

I am using varName = setInterval(function() { ... }, 1000); to set a couple of intervals in a jquery plugin that I'm writing, but when the plugin is reloaded I need to clear those intervals. I tried storing them in variables, like this: (function($){ $.mosaicSlider = function(el) { var base = this;...
Nikolay Dyankov
4

votes
4

answer
11.9k

views

Blur screen with iOS 7's snapshot API

I believe the NDA is down, so I can ask this question. I have a UIView subclass: BlurView *blurredView = ((BlurView *)[self.view snapshotViewAfterScreenUpdates:NO]); blurredView.frame = self.view.frame; [self.view addSubview:blurredView]; It does its job so far in capturing the screen, but now I wan...
Nikolay Dyankov
3

votes
1

answer
2.4k

views

Node.js + setInterval = Connection lost: The server closed the connection

I have a simple Node.JS script (just a script, no server), which is supposed to do a thing every 24 hours. But after about 8 hours I see this in the error log: Error: Connection lost: The server closed the connection. at Protocol.end (/home/user/dev/app/node_modules/mysql/lib/protocol/Protocol.js:73...
Nikolay Dyankov
7

votes
3

answer
11.8k

views

context.getImageData() on localhost?

I have the following snippet of code and I'm trying to run it from localhost (OSX, running XAMPP): var canvas = document.getElementById('mycanvas'); var cx = canvas.getContext('2d'); var myImg = new Image(); myImg.src = 'images/lion.jpg'; $(myImg).load(function() { cx.drawImage(myImg, 0, 0); var img...
Nikolay Dyankov
3

votes
0

answer
556

views

iTunes Connect - how to remove a company CONTACT?

I am trying to remove an old contact that is bugging me sitting in the menus. It appears when I click Contact Info for a contract and then look in the menus under 'Company Contacts'. There is a button to ADD a company contact, but I can't find how to remove one? Any ideas? This is what support said:...
Nikolay Dyankov
13

votes
2

answer
3.7k

views

Node.js forever module - get path to a script that is running?

When a script is running with the forever module and you 'forever list', you get a list with the filenames of all currently running scripts. In this case, 'myscript1.js' [0] j2mo /usr/local/bin/node myscript1.js 51004 51005 /Users/me/.forever/j2mo.log 0:14:10:51.420 [1] Vav3 /usr/local/bin/node m...
Nikolay Dyankov
5

votes
6

answer
2.1k

views

jQuery plugin - inline CSS or external stylesheet?

I'm coding a jquery plugin and I'm thinking whether I should move all the CSS in the .js file, just to make it a little bit easier to setup. Should I do this? Is it too bad, performance wise?
Nikolay Dyankov
14

votes
2

answer
11.9k

views

iOS HTTPS requests 101

NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) Very, very frustrating! I've been pulling my hair for hours with this. I'm using a self-signed certificate on my Linode server. The port is 8000, couldn't get it to work on 443. I don't believe this is the reason thoug...
Nikolay Dyankov
2

votes
1

answer
374

views

How to test facebook insights for an iOS app?

I completed all steps here: https://developers.facebook.com/docs/ads-for-apps/mobile-app-ads/ ... and installed the SDK properly in my app: [FBSettings setDefaultAppID:@'xxxxx']; [FBAppEvents activateApp]; I also added all necessary keys in the info.plist file. My end goal is to run mobile app ads a...
Nikolay Dyankov
4

votes
1

answer
2.8k

views

MongoDB, Mongoose - Slow query when fetching 10k+ documents

I have a MongoDB database with 10-12k documents in a collection and I'm experiencing really slow queries when attempting to fetch all documents, like this: Sales.find() .where('author').equals(author) .where('date').gt(startDate.unix()).lt(endDate.unix()) .exec(function(err, results) { callback(); }...
Nikolay Dyankov
2

votes
1

answer
5.3k

views

socket.io can't get it to work

EDIT 1: Ok, problem with the server solved. This is the full server code integrated into my project. var http = require('http'); var express = require('express'); var requestHandler = require(__dirname + '/app_modules/request-handler.js'); var app = express();...
Nikolay Dyankov
3

votes
3

answer
3.4k

views

Unknown column in where clause in C# app

I am trying to develop C# app where I want to have login form connected to remote server. I connected to the server but when I try to login, the line : MySqlDataReader reader = cmd.ExecuteReader(); is giving me an error: Unknown column 'admin' in where clause Do you have any idea from where can com...

View additional