SyntaxFix.com - Programming Questions & Answers Hub For Beginners

Some Of The Best Answers From Latest Asked Questions

Preg_match backtrack error

When I use the regex (.*)*[0] everything works well: preg_match('/(.*)*[0]/', 'this is a test string'); var_dump(preg_last_error()); // no code's returned But when I add another character to char class, it will throw out error: preg_match('/(.*)*...

Parameter binding on left joins with array in Laravel Query Builder

I trying to do a left join with where IN clause search. But I couldn't able to bind the array to the query. $query = DB::table('offers'); $query->select('id', 'business_id', 'address_id', 'title', 'details', 'value', 'total_available', '...

Setting default checkbox value in Objective-C?

Okay, this one's making me feel stupid... I'm a feature film editor who's recently started teaching myself Objective-C after many years away from coding. I think the last code I wrote was in Cobol, if that gives you any indication. Anyway, I've rec...

Highlight Anchor Links when user manually scrolls?

I apologize for the long post. I wanted to include everything that might be helpful. I have a single page website that consists of several divs stacked vertically. I'm using a floating nav bar and softscroll.js to make anchor links move to the divs ...

Intermediate language used in scalac?

In the GCC compiler we see several 'intermediate languages': RTL, GENERIC and GIMPLE. This answer hints at the idea of an intermediate representation in scalac. My question is: is there an 'intermediate representation' of the compiler in Scala? I...

Generating a list of pages (not posts) without the index file

I am using Jekyll as a static generator for a website (not a blog), and I want to have an automatically generated list of all pages on my index page. I get that to work with the following code for the sidebar.html file: <ul> {% for page in s...

Warp \ bend effect on a UIView?

I'm trying to get a similar effect to the one described in the pictures. The white area on the left isn't on the original photo, it pushes the pixels away. I've tried using Core Image (which offered a few close effects to this) but it was too slow fo...

Why there is this "clear" class before footer?

I have recently been modifying a template from Blogofile, which is written in HTML 5. When I looked at the generated page, there is this <div class="clear"></div> box in the html source code before footer. What does this mean? How do ...

Generic XSLT Search and Replace template

I am trying to find (before re-inventing) a "simple" XSLT template that will take ANY xml document, find ALL text elements within that XML and replace all ' with ''. I'm doing a "SELECT ... FOR XML" from SQL and then "saving" that XML for later inse...

Are all Spring Framework Java Configuration injection examples buggy?

I'm wondering if it's only me or are most examples of Spring's Java Configuration flawed? Like here for example: http://spring.io/blog/2008/03/27/spring-java-configuration-what-s-new-in-m3 http://spring.io/blog/2013/07/18/javaconfig-support-in-the-...

Calling another method java GUI

I'm trying to make a GUI, and I can accomplish it all in one method, but I would like to make the code simpler and make multiple methods. However, I can't get it to work. I am new to Java programming. public class Main { public static void main...

Use NSInteger as array index

Have a happy year! I am having trouble with the following. First logic: Get json from server. Json value is always a number. Read plist into array. NSLog the array with index of the json value from server. My plist: Key Type Value Item 0 ...

I need to know how to get my program to output the word i typed in and also the new rearranged word using a 2D array

I have a working program which takes the first letter of a word then switches it to the back of the word and adds "ay to the end. It works fine but I am trying to store the original word and the newWord in a 2D array and output all contents of the a...

Summing radio input values

I'm new to this so I have been trying to adapt code from others to suit my needs, I need a radio selection from the first name group to be added to the second name group and then displayed in the text box at the bottom. Nothing appears in the bottom...

Removing "http://" from a string

I have a PHP script that removes the "http://" from user input url strings. My Script: $url= "http://techcrunch.com/startups/"; $url = str_replace('http://', '', $url); Result: $url= techcrunch.com/startups/ This works great, except that somet...

Is it possible to change the content HTML5 alert messages?

Is it possible to control HTML5 alert messages? when adding 'required' to an input field. because I want it to be specific and I don't want it's language to depend on the browsers. <input id="answer" required> ...

Java and unlimited decimal places?

Is there a simple way that i can manipulate high precision decimal numbers in java, without a limit on the number of decimal places, and the ability to output the number in a println or write it to a file? I want to work with one of the identities of...

Zipping a file in bash fails

I have this line of code in a file called backup.sh, located in /backup (so the path is /backup/backup.sh) The code is: #!/bin/bash zip -r /backup/Backup-$(date +%Y-%m-%d) /ftb The file has permissions 777. However, it errors with: -bash: /ba...

is it possible to add colors to python output?

so i made a small password strength tester for me, my friends and my family, as seen here: import re strength = ['You didnt type anything','Terrible','weak sause','avarage','Good!','Very Strong', 'THE FORCE IS STRONG WITH THIS ONE'] score = 1 passwo...

Read input from a JOptionPane.showInputDialog box

I am almost done with this project. It's my very first one and I need to read a little better the inputs from the JOption box. For example, I want to go back to the previous page if the user clicks on "cancel" or close the program. So far, every tim...

Cannot retrieve string(s) from preferences (settings)

I have encountered a problem in my Android application. The problem is that for some reason, I can't retrieve the string of a ListPreference from my preferences.xml file. Here's the code I tried: private void showUserSettings() { SharedPrefere...

strange error in my Animation Drawable

A strange error when trying to start Activity. i think the error in my Animation Drawable LogCat: 12-31 06:37:45.138: E/AndroidRuntime(922): FATAL EXCEPTION: main 12-31 06:37:45.138: E/AndroidRuntime(922): java.lang.RuntimeException: Unabl...

How to execute an action before close metro app WinJS

I want to trigger a function before closing my metro app but I don't know where such as app.onactivated = function (args){ //all the actions here will be executed on app's activation } I want something for deactivation or app's closure, what's t...

Two Page Login with Spring Security 3.2.x

We are brand new to Java, Spring, and Spring Security, but not new to development. We've been able to create a Spring Security-based Thymeleaf login page that uses a JNDI datasource to connect to our SQL Server database using BCrypt encrypted passwor...

Hadoop MapReduce: Strange Result when Storing Previous Value in Memory in a Reduce Class (Java)

If I wish to store the current value of an iterator to compare to the next value of the iterator in a Reduce method, Hadoop requires that I clone it instead of simply assigning its reference to a temporary variable. I am about to post the code to my...

javascript, for loop defines a dynamic variable name

Folks, Not sure if eval() or window() is the answer, but I am trying to loop through an array, and create variables for each item in that array dynamically. My myArray looks like: ['foo','bar','baz'] code: for (var i = myArray.length - 1; i &g...

How can compare-and-swap be used for a wait-free mutual exclusion for any shared data structure?

Being new to multi-threading and mutexes I was going through the wikipedia for starters. I came across this portion: CAS can be used to achieve wait-free mutual exclusion for any shared data structure by creating a linked list where each node rep...

How do I hide the PHP explode delimiter from submitted form results?

I have created a form which utilizes a .txt file to pull the names of the EMPLOYEES from and breaks them up in the SELECT form option using the PHP explode function. <select name="FakeName" id="Fake-ID" aria-required="true" required> <opti...

Got a NumberFormatException while trying to parse a text file for objects

While trying to create objects and add them to an ArrayList using data from a text file, the program threw a NumberFormatException and I have absolutely no clue why, everything seemed OK to me. Here's the method in which the exception occurred: sta...

Best way for storing Java application name and version properties

Using Eclipse IDE. I need to store my application's name and version as they are used by the app itself. I could hard-code them as static final fields somewhere in the codebase. A better solution I know about may be storing them in the manifest file...

Problems with installation of Google App Engine SDK for php in OS X

I'm trying to create Google App Engine environment in my Mac OS X Mountain Lion. Downloaded the Googleapplauncher.dmg file. While I tried to unzip the file it shows "the following disk images couldn't be opened" . Reason: "Not recognised"....

How is VIP swapping + CNAMEs better than IP swapping + A records?

I'm in the middle of updating my DNS setup to use all CNAMEs instead of A records, because I need support for VIP swaps between Staging and Production. I can't use A records for this because that puts a dependency on a VIP that will be changing for ...

Get Public URL for File - Google Cloud Storage - App Engine (Python)

Is there a python equivalent to the getPublicUrl PHP method? $public_url = CloudStorageTools::getPublicUrl("gs://my_bucket/some_file.txt", true); I am storing some files using the Google Cloud Client Library for Python, and I'm trying to figure ou...

Access And/Or exclusions

I have some sample data like: |H.RISK|NOTE|NORMAL| The | are actually in the data, it's a String. I am using Access, and am trying to exclude records that contain RISK in the String. Sample query: SELECT * FROM someTable WHERE (UCase(someTable....

Querying date field in MongoDB with Mongoose

I'm trying to query documents in MongoDB using findOne(), but it's not working. The field I'm trying to filter by is 'date', and I'm not sure if perhaps it's a special word I shouldn't be using when inserting docs. Is there something I'm missing? Mo...

Uploading into folder in FTP?

I am using the following code to learn how to load files with FTP. How do I set the path or folder into which my file will be uploaded ? using System; using System.IO; using System.Net; using System.Text; namespace Examples.System.Net { public ...

Speech input for visually impaired users without the need to tap the screen

We're working on a app for blind and visually impaired users. We've been experimenting with a third party library to get spoken user input and convert it to text, which we then parse as commands to control the app. The problem is that the word recogn...

Image steganography that could survive jpeg compression

I am trying to implement a steganographic algorithm where hidden message could survive jpeg compression. The typical scenario is the following: Hide data in image Compress image using jpeg The hidden data is not destroyed by jpeg compressiona nd c...

Getting all files in directory with ajax

Backstory: I am creating a development tool for web development. This tool loads a users webpage into an iframe, this allows the program to resize the iframe and simulate mobile screen sizes. I also want to build in a tool that automatically refreshe...

how to put image in a bundle and pass it to another activity

is there a way to put an image in a bundle and pass it to another activity? i've done my research and came up with putParcelable but i don't know how to get the passed image from the other activity and how to set the image to an imageView. i'm stuck ...

Call japplet from jframe

I Designed JApplet class manually and I designed main class by using Netbean Builder which generate the code automatically by default the class will be extends JFrame. so how can I run the JApplet class from JFrame . this JApplet code the problem now...

FragmentActivity to Fragment

I haven't found any question like this on here so I wanted to ask. Please keep in mind that I'm new to Fragments & FragmentActivity (not Android) and I don't really know how to work with them quite yet but I'm learning. My question is I want to k...

RegisterStartupScript from code behind not working when Update Panel is used

I have created a radiobutton list followed by one button. I can select one of the item from the radiobutton list and then click the button to execute something. And I want the page to pop up a window if the button is clicked without selecting any of ...

How to integrate Dart into a Rails app

How should I go about integrating my Dart application, into my rails application. I'm having a hard time with the whole, 'packages' structure that has to exist on every directory. Because the subdirectories reference the root using an alias, rails i...

Why does calling sumr on a stream with 50 tuples not complete

While investigating a bug today, I noticed that calling sumr on a stream with 50 (Int, Int) tuples never completes, but it does on a smaller stream. Calling .toList on the larger stream first completes as well. Is this the intended behavior when ca...

Real time face detection OpenCV, Python

I am trying to make a basic program for a real time face detection. Here's my code (I am a newbie in OpenCV) : import numpy as np import cv2 cam = cv2.VideoCapture(0) name = 'detect' face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_defa...

vagrant primary box defined but commands still run against all boxes

I am trying to set my "dev" VM as primary so most commands such as vagrant up, vagrant halt, etc operate on the "dev" VM and ignore the "stage" VM unless the "stage" VM name is explicitly listed on the command line. Here's my Vagrantfile, but when I ...

500 Error on AppHarbor but downloaded build works on my machine

I'm using Visual Studio 2013 on Windows 8. I have a web service built off ServiceStack. Everything works fine on my machine but when deploying it to AppHarbor I get a 500 error. I set customErrors mode="off" and I still get a 500 error with no stack ...

Are these methods thread safe?

i have the following static class with generic methods and i'm wondering if it's safe to use it from different threads and with different objects? i'm not sure how this works below the covers so an explanation of would help public static class Seria...

Laravel 4 with Sentry 2 add user to a group on Registration

So, I'm trying to implement Sentry 2 with Laravel 4.1. I'm using this resource for it https://github.com/rydurham/L4withSentry Everything works fine, but now I want to assign user to a group automatically when he registers. From Sentry 2 Docs, ...

Drag and drop menuitems

I want to rearrange menuitems by drag and drop in my firefox addon like the bookmarks in the Bookmarks menu. Specifically, I want the blue insertion marker to appear while dragging a menuitem over valid places. Can someone show me how to do this or t...

make UITableViewCell selectable only while editing

I have a UITableView where the selectionStyle is set to UITableViewCellSelectionStyleNone because I don't want any visible change when a cell is tapped, but when it is in editing mode I do want the the cell selectable so the checkmark appears for eac...

Rails 2.3.4 Persisting Model on Validation Failure

I have a standard html form post that is being persisted and validated with a rails model on the server side. For the sake of discussion, lets call this a "car" model. When car.save is invoked the validators fire and set a list of fields in er...

Is it possible to execute multiple _addItem calls asynchronously using Google Analytics?

Would the following code work? _gaq.push(['_addTrans', '7171717117', // order ID - required '', // affiliation or store name '2222', // total - required '', // tax '', // shipping '', ...

php & mysql query not echoing in html with tags?

<?php require 'db.php'; ?> <?php if (isset($_POST['search'])) { $limit = $_POST['limit']; $country = $_POST['country']; $state = $_POST['state']; $city = $_POST['city']; $data = mysqli_query($link,"SELECT * FROM proxies WHERE country = '{$c...

Comparing two joda DateTime instances

I have a problem with the comparing two DateTime objects. System.out.println(response.getCreationDate().toString()); // will return "2013-12-31T22:59:21.000+01:00", but... assertThat(response.getCreationDate(), equalTo(new DateTime("2013-12-31T22:5...

How do I show a message in the foreach loop?

A user goes to the URL: http://mywebsite.com/index.php?company=walmart Once the page loads i want to check if the registered user can access this people. To do that i check with an array save in session for the user. Array ( [0] => ebgames [1] ...