Every time when i submit the same code for Third exercise: function draw_ball(), i get different output mistakes for different tasks. https://tmc.mooc.fi/mooc/paste/jh_mdp54v1QFJ8McJdb4qQ#stdout
mercredi 31 août 2016
How do I stop scanf loop after user enters specific amount of integers?
#include <stdio.h>
int main(void) {
double numbersEntered, sum = 0;
do
{
printf("Enter a number: ");
scanf("%lf", &numbersEntered);
sum += numbersEntered;
}
while (/* ??? */);
printf("Sum = %.2lf", sum);
return 0;
}
What should I do in the while
statement to stop the loop after the user enters 4
integers?
File can't open due to permission
I could not get the permission to communicate with com port 7 and received this error:
Warning: fopen(.COM7:): failed to open stream: Permission denied in C:xampphtdocssmstest4.php on line 3
Uh-oh. Port not opened. Please help me to get permission in Windows 7?
About if else staetment
here is the code!
code1 :
if(false) {
//1000 lines of code
}
else {
//1 line of code
}
code2 :
if(false) {
//1 line of code
}
else {
//1 line of code
}
what will be the process time of above two codes? Also please try to explain...
How can I scale an image using tcpdf?
I've got an image of size 490 x 630 that was drawn in corel. It's supposed to have 41.3 mm (wide) and 52.3 mm .
The unit I'm using in my TCPDF class is "mm".
I'm having trouble trying to acomplish this.
What value should I put on setImageScale() ?
Thanks !
strange occures when cmake freeDiameter1.2
I'm making install freediamete1.2 and got a strange error and I'm stuck for a couple of days.
The error is showed as below:
What's the time complexity of this while loop?
while(n>x)
x*=x;
The correct answer is log(log(n)), I can see the log(n) since x^k>=n is when the while loop will stop. so I got to log(n), what am I missing?
P.S: it is given that x=2.
C Standard - Comma Operator Syntax
according to the C Standard (and K&R) the syntax of the Comma-Operator is as follows:
expression:
assignment-expression
expression, assignment-expression
But why does this statement work?
5+5, 1+1;
5+5 and 1+1 are not assignment-expressions, but the C Standard requires assignment-expressions as operands for the Comma-Operator.
How do I programatically force an onchange event on an input?
How do I programatically force an onchange event on an input?
I've tried something like this:
var code = ele.getAttribute('onchange');
eval(code);
But my end goal is to fire any listener functions, and that doesn't seem to work. Neither does just updating the 'value' attribute.
Is it ok to save order ID on clients' side as cookie?
Can someone abuse this order id to hack someone's detail? I am saving this for a notification feature. I just want to identify unique order made by customers. I've figured out order ID is the most unique data that I can think of. Please let me know if there's any security issue with this.
Disable automatic upload in mini-ajax-file-upload-form/
I use Mini ajax upload (http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/) to upload images.
I want to disable the automatic upload and do it with a submit button.
The autoUpload: false,
in jQuery.fileupload.js doesn't work.
Any idea ?
how to change invoice and delivery order number in virtuemart
how to change invoice number and delivery number in virtuemart like this the starting invoice number will be 9546900001 & delivery order number will be DO953700001....... Invoice number 95469 will be fixed and only 00001 will increase, once reach 99999 will move to 100000.Delivery order number DO9537 will be fixed and only 00001 will increase. Please help me! Thks!
Swift - How to find <img> tag and its attribute 'src' in HTML string
enter image description hereI have an HTML string which I extracted from url. I need somehow find first <img>
tag. In a nutshell I need to implement querySelector('img').getAttribute('src')
in swift. Any suggestions?
Writing a portable C program - which things to consider?
For a project at university I need to extend an existing C application, which shall in the end run on a wide variety of commercial and non-commercial unix systems (FreeBSD, Solaris, AIX, etc.).
Which things do I have to consider when I want to write a C program which is most portable?
security risk of disclosing php files name
I am developing a web application using a laptop server wamp. when I inspect my page using DevTools on chrome, i can still see the name of the php files (with their extensions). is disclosing the php files name of my application risky? if yes how can I hide them?
thanks.
Call Javascript Specific Function from external file with same name that other
I have a custom function named tooltip() for another issue but I need to use the tooltip() function of bootstrap.
How could I call those specific tooltip() function of bootstrap?
Executing this I am calling mi local function tooltip():
$('[data-toggle="tooltip"]').tooltip();
Thanks
How do I record JSON data to file using PHP?
This is the code I've figured out.
<?php
$username = $_POST['username'];
$email = $_POST['email'];
$json = '{"username":"'.$username.'",'.'"email":"'.$email.'"}';
$file = fopen('token_data.json','w+');
fwrite($file, $json);
fclose($file);
?>
But this is absolutely not the right way.
How to pass LIST to view as JSON in MVC asp.net
Laravel 5 - Call to undefined method IlluminateDatabaseEloquentCollection::Paginate()
I'm having an error
Call to undefined method IlluminateDatabaseEloquentCollection::Paginate()
I've been doing this:
public function index ()
{
$articles = Article::latest('published_at')->published()->get()->paginate(5);
$articlesLink = $articles->render();
return view('articles.index', compact('articles', 'articlesLink'));
}
How do I switch this script from INSERT to UPDATE
I would like to change this to UPDATE... Can someone please write the script for me... I've tried for a couple of days with no success. Thank you for your help!
$query_upload="INSERT into images_tbl (images_id, `images_path`) VALUES ('".$_SESSION['user_id']."', '".$target_path."')";
Underscore JS, find object which contains value in array
Im looking for a solution to find json object which contains a value in b. example: find objects which contain "jinx" in b.
sample data. [{ id:1 a:"karma", b:["jinx","caitlyn","tristana"] }, {....}, {....}]
I understand underscore works better for key/value pairs but this would be of great help.
Thanks.
issue with mysqli function
My page displays this error "mysqli_query() expects at least two parameters, one given on line $result=mysqli_query($connect);"
Here is my code:
mysqli_query($connect,"SELECT
*FROM $tbl_name WHERE phone
='$phone' and
password= '$password'");
$result=mysqli_query($connect);
$count=mysqli_num_rows
($result);
if($count==1){
....}
PhpStorm Access to Database
I am trying to change values in my database, but I am always getting this error :
This table is read-only. Cell editor changes cannot be applied.
But it´s not set to this value, I can access it freely with any other php script. Any ideas that might help?
Declare variable let in javascript ECMAScript6
Why is it possible to declare variable named let when I can't declare const or var. I know I will never do that , but I am just curious if there is reasonable explanation. So I can do:
var let = 5;
let x = 3;
x + let -> 8
Why is this even possible?
mardi 30 août 2016
lstat doesn't detect symbolic link
I'm trying to check if a file is a symbolic link, my test doesn't seem to work. How can I check for symbolic links?
if (lstat(file->full_path, &file_info) == 0)
printf((file_info.st_mode & S_IFDIR) ? "l" : "");
else
printf((S_ISDIR(file_info.st_mode)) ? "d" : "-");
PHP get yesterdays date unless weekend
I need to get yesterday's date to show the market close date. This only applies to Monday through Friday as the markets are not open on the weekend. Using this format how would I do that?
<?php
$yesterday = date("Y-m-d", mktime(0, 0, 0, date("m") , date("d")-1,date("Y")));
echo $yesterday;
?>
PHP reg ex allow all letters in all alphabets
I want to create a reg expression in PHP to allow all letters in all alphabet including Cyrillic, Greek Chinese etc and also allow numbers, dot and underscore. First three characters must be letters (all alphabets).
This will be used to validate a username so no spaces.
$regex = p{L};
Initializing a char with an int in C
I am new to C programming and would like to create a char that puts text before an int.
char charPin[] = ("PIN%d",pin);
I want it so I can pass charPin
to an external function. I am receiving an invalid initializer on the beginning of the line.
How to set height and width of an image object in js
I have this array of image objects and I want to set the height and width if possible inside the array, because I have tons of images which I put in a table and I want them all to be the same size. Any ideas?
function myFunction(){
var imagelist = [{"image":"image3.jpg"}];
}
How do I set an image as a background in React?
I have a <div style={styles.background}></div>
Is it possible to do something like this?
import image from 'img/image.jpg';
const styles = {
background: {
background: `url(${image})`
}
};
export default styles;
I know that won't work, but is there something similar to that?
AJAX JQuery delete data
Help, I have a big problem with ajax, I deleted records using ajax, using confirmation window bootstrap, very well when I press the button to delete it runs correctly and the table refreshes without any problem, the problem is that when I want to remove another record, opens the modal window bootstrap, but do not run anything
Stack smashing detected
I am executing my a.out file. After execution the program runs for some time then exits with the message:
**** stack smashing detected ***: ./a.out terminated*
*======= Backtrace: =========*
*/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)Aborted*
What could be the possible reasons for this and how do I rectify it?
Javascript REGEX matching two brackets [[something]]
trying to match anything width and including two brackets e.g. [[match this]]
so I can replace without brackets.
here is what I have as far var regex = /([[|]])w+/g;
However this matches the above like this [match
Any help would be appreciated
Case Insensitive String comp in C
I have two postcodes char*
that I want to compare, ignoring case.
Is there a function to do this?
Or do I have to loop through each use the tolower function and then do the comparison?
Any idea how this function will react with numbers in the string
Thanks
Socket communication in char device driver
Is it feasible to open socket from kernel module of a char device driver in linux? I am trying to emulate the output / input stream of char devices over network. But as far as I searched opening a socket from char device is not possible? Any other option to access udp / tcp ports from char device drivers?
how to only use created_at in laravel
everyone.
I am new to laravel.
this is my questions:
this can custom timestamps name
const CREATED_AT = 'created';
const UPDATED_AT = 'updated';
this can disable timestamps
public $timestamps = false;
I want only use created_at , how to do it ?
Counting number of code points in a LPTSTR
What is the recommended way to count the number of code points (not code units) in a LPTSTR
in C? wcslen()
isn't helpful here because it returns the number of code units, but I need the number of code points in the LPTSTR
, i.e. the number of characters in the string.
I am getting an unexpected error that does not make sense to me
line 3: syntax error near unexpected token '('
line 3: 'int main () {'
#include <stdio.h>
int main () {
int x;
char c;
printf("1. Shape Printern");
printf("2. Circular Charsn");
printf("3. Factorsn");
printf("4. Exitn");
printf("What would you Like to do? n");
scanf("%d %c" , &x, &c);
return 0;
}
How to prepare a .exe file of a php gtk application
<?php
$window = new GtkWindow();
$button = new GtkButton('Hello word!'); //$button->connect('clicked','olamundo');
$window->add($button);
$window->show_all(); Gtk::main();
?>
Codes are here. I run it and see result of hello.php but i want to find exe file of hello.php. How to find this file ?
how to use INNER JOIN and IN Clause in same query
i have three tables and want to run INNER JOIN and IN clause on them. can anyone tell me where i am doing wrong
SELECT `tblinvoices`.id,`tblinvoices`.userid,`firstname`,`lastname`
FROM `tblinvoices`
WHERE `paymentmethod`IN
(SELECT `gateway` FROM `tblpaymentgateways` WHERE `setting`='type' AND `value` = 'CC')
INNER JOIN `tblclients` ON `tblinvoices`.userid=`tblclients`.id"
Why write() to STDIN worked?
I have the following code:
int main()
{
char str[] = "Hellon";
write(0, str, 6); // write() to STDIN
return 0;
}
When I compiled and executed this program, "Hello"
was printed in the Terminal.
Why did it work, did write()
replaced my 0
(STDIN) argument with 1
(STDOUT)?
&char and char pointer is incompatible pointer type?
char filename[100];
char *file;
fgets(filename,100,stdin);
file =&filename;
give this warning:
warning: assignment from incompatible pointer type [enabled by default]
file =&filename;
Isn't &filename and file have the same type as address of character since i use & to get address of the variable?
Why string assinging pointer is not conceder as dangling pointer?
Why we mention string assigning character pointer as a dangling pointer in below code ?
void func()
{
char *ptr;
*ptr = "dog";
char *p1 = malloc(sizeof(char));
char *p2;
*p1 = 'a';
*p2 = 'b';
}
Here p2
is called 'Dangling pointer' but *ptr
is not calling dangling pointer. Why is it so ?
How to get notified whenever anything happens to an x window? [on hold]
I'm looking for a way in c or c++ to get notified whenever a new window opens, a window closes or when a window gets mapped or unmapped. I'm guessing you'd have to use Xlib but I'm not sure. If anyone can tell me about what libraries and functions I need for that, I would really appreciate it.
How to register JavaScript helpers with Handlebars.net
How would we register these two JavaScript helpers in Handlebars.Net?
For Moment.js:
Handlebars.registerHelper("formatDate", function (datetime, format) {
return moment(datetime).format(format);
});
For a java script calculation:
Handlebars.registerHelper("formatPercent", function (val1, limit) {
return Math.ceil(100 * val1 / limit);
});m
Difference between linefeed and newline
This sentence from k&r:
A text stream consists of a sequence of lines; each line ends with a newline character....For instance, the library might convert carriage return and linefeed to newline on input and back again on ouput.
How can you convert linefeed to newline and why is it done?
Reference .css and .js files in google chrome
Is there any problem if I reference .css and .js with "~/file.ext" for chrome? Because I get some layout errors when I do it this way. Does chrome want it like "../" instead of "~/"? I am developing with Asp.Net Core and I just drag and drop the files from the Solution to the Html to create the references.
FIle search in C language [on hold]
Hello I just wanted to know how can you scan for a particular number in a file, for example a #ID in an employee file record?also, I just wanted to add that #ID is part of a struct Employee and I'm using a sequential file and well one final thing is that I'm using the C languaje Thanks!!!
lundi 29 août 2016
Why break cannot be used with ternary operator?
while(*p!='�' && *q!='�')
{
if(*p==*q)
{
p++;
q++;
c++;
}
else
break;
}
I have written this using ternary operator but why its giving error for break statement?
*p==*q?p++,q++,c++:break;
gcc compiler gives this error: expected expression before ‘break’
How to get the size of memory pointed by a pointer?
I am currently working on a NUMA machine. I am using numa_free
to free my allocated memory. However, unlike free
, numa_free
needs to know how many bytes are to be freed. Is there any way to know that how many bytes are pointed to by a pointer without tracing it out?
ELF Header Size Greater than 52 bytes
According to the given Elf32_Ehdr structure (page9) in the link elf-format elf header size should be 52 bytes and fixed. But there is also field e_ehsize and can be greater than 52 bytes. In where defined those extra bytes until first section header starts ?
Write a 2D array into a file without changing it's previous content
I need to write the contents of a matrix into a file.
The 2 dimensional matrix is:
char encodedInst1[20][20]
I want to pass the updated matrix to a function which writes it to the output file without altering the previous content.Moreover each string should be written in a a new line.
Get IP input from user and validate WINAPI
How can I get the IP that a user inserts in a IP Control box in Winapi, in a way that I can validate it after?
Already tried GetDlgItem() but it doesn't seem to store the IP in the correct format, maybe I'm doing it wrong. I was storing it as a DWORD.
Any tips?
select with update in one query
I have a query like:
SELECT id, name, surname, fromId, toId, msg_text, readed FROM messages WHERE toId = 2;
So I want to update all selected rows.readed = 1
. And Query must return all selected rows.
These action must do in one query if possibe.
Sorry for my english
Can website visitors see server-side source code?
I want to make sure visitors to my site can't see the PHP code that's generating the page. Here is a reference: http://may.edu.np/tmp/
Can anyone explain to me how server-side scripts are interpreted and how the result is delivered to the end user?
Detect the MSS size of TCP session in php
When a HTTP request is made by clients behind VPN, the initial TCP handshake would have a MSS much less than the standard one (1460). Wonder if it's possible for a php script to get this information and process the request differently.
If possible, some hackers may program it to distinguish requests from security researcher or some security products.
How to compare socket address in C?
I mean, which fields of struct sockaddr
should I compare when I check whether two struct sockaddr
's have the same ip address and port number? And what about sockaddr_in
?
Can I just cast sockaddr_in
to sockaddr
, and compare it to a real sockaddr
?
Cakephp read and write json files.
I am new to cakephp. I am trying to save json output as a file in webroot. I would also like read the file into a array.
I know we could output array as json object using json_encode($array). But I am stuck creating and reading json files into an array.
I appreciate any help.
PhpStorm warning - Cannot resolve directory - a href without file extension
I have PHP files and a href links that lead to these files but without the file extension. PhpStorm outputs the messages "Can not resolve directory. This inspection checks unresolved file references". Example:
File path: /account.php
<a href="/account/">...</a>
Is in PhpStorm any setting to resolve this problem?
PHP json_decode returns int(1)
I'm having some trouble accessing a json string - Demo Link
//PHP CODE
$json = curl_exec($ch);
$json = json_decode($json, true);
var_dump($json);
// RESULTS
@{"error":"Bank account validation failed.","error_type":null,"code":400}
int(1)
Any help would be highly appreciated!
Counting contractions as 2 words instead of 1 in str_word_count()
I'm trying to get the word counts of a string, but I want to count contractions as 2 words instead of 1. Is there a way to do this with str_word_count()?
$string = "i'm not";
$count = str_word_count($string);
echo $count;
Result:
2
Want Result:
3
Which is better to use in Laravel 5.2 redirection?
I am newbie in Laravel and I am using Version 5.2, and I wanna know what is better to use in return value on redirecting routes in my Controller.
return Redirect::route('home');
or
return redirect()->route('home');
Please indicate your source(s) in there are any.
Set console background color in node.js
I'm re-coding a c# program in node.js but I don't found a func to set the background color in node.js docs.
Sorry for my bad english, I'm brazilian
Adding a custom library to c programs
I am using Ubuntu Linux I have made a custom static library Mylib.a, I can include it to only those c files which are in the same directory as the static library.
I want to make it a general library so that I can include the library file to any c file I want irrespective of its location
Why should the system() function be avoided in C and C++?
I have seen a lot of people on forums telling to avoid the system()
function, like system("cls")
. I don't understand why.
Please tell me why I should avoid this function. And also, as clrscr()
doesn't work with CodeBlocks, what are other ways to clear screen without using the system()
function?
How to place "Enter Coupon Code" in sidebar Cart?
I'm using the sidebar cart as a SlideIn Cart on the Productpage. From this Cart, the customers goes directly to the one page Checkout. Now I want the Customer to be able to enter a Coupon Code on that Page.
In the Sidebarcart on the Productdetailpage.
Does anyone have a hint for me or realized something similar?
Is there one include file that covers all file operations?
OK, maybe not, but which ones do you need in order read, write and delete files and directories? I've got stdio.h and stat.h and now I find I need unistd.h in order to use unlink. I've never heard of unistd.h. Maybe I should be using something else besides unlink? Right now I'm using C on Linux Mint.
Disable key ESC ALERT Javascript
Hello I have the next code:
$(function () {
var int = self.setInterval(function () {
alert("Session expired.");
location.reload(true);
}, 60000);
});
I want to disable the Esc key and thus prevent the alert out of execution. Also if anyone knows how to assign a CSS without using jquery alert Please tell me they are greatly appreciate.
Serial Number Detection with openCV
I have a video with a serial number. Like in the picture. How I can with openCV detect the position of this patron. The only thing that I need is detect the location of this patron. Always this patron will have 12 numbers and will be white.
Reparsing project in Nebeans
Is there any way to auto re-parse project in netbeans while practicing c or c ++ ? I am new to c program in netbeans. It says unable to resolve identifier while wrinting ststements and lines in C program. So, it would to nice to know if there is an way for auto reparse mode to prevent reparse in every second line. Thank you
Position:fixed toolbar in a div next to a dynamic width side nav
I have a side nav that can be collapsed. I want my toolbar div to be fixed to the top and fill the rest of the width. 100% causes it to go off the page. I can't do a calc() because of the dynamic width of the sidenav.
How can I set a position: fixed div to fill the remaining width?
My program doesn't compile
#include <stdio.h>
#include <math.h>
#include <cs50.h>
int main (void);
{
int x=0;
x=GetInt();
for (x<10)
{
printf("Hellon");
i++;
}
return 0;
}
It says an error:
expected identifier or '('.
It seems to not allow me to compile. I'm probably doing an error.
Convert image with mogrify and output it to variable
I am trying to convert a bmp
to jpg
with mogrify.The jpg should then be store in a variable.
Here is my attempt thus far
$jpg_content = shell_exec("gm mogrify -format jpg ". escapeshellarg($image) . " && cat " . escapeshellarg($image)."2>&1");
However $jpg_content
is null
dimanche 28 août 2016
Find a string from group of string and take the value using php
we have a group of string like white-1,black-2,blue-4
etc . This is the string format .
ie : name1-name1 value , name2-name2 value
etc .
From this string i need to take the associated value . For example value of white is 1 , value of blue is 4 etc .
How can i do this ?
php yii framework :: $content is not found
<div class="content">
<?php echo $content; ?>
</div>
<?php echo $this->renderPartial("/site/_footer",null,true,false); ?>
this is my code.
there is variable in code $contant.but i cant able to find the variable anywhere.
pls help me
How to use substring() when the string has a space in it
I have a string containing a person's first and last name such as John Doe
. I would like to convert this string to John D.
Normally, I would just use substring(0,1)
on the last name variable, but how can I achieve this when the first and last name are one string with a space in between?
How does .waypoint work?
If a have a code like this
var waypoint = new Waypoint({
element:document.getElementsByClassName ('waypoint'),
handler: function(direction) {
console.log('Scrolled to waypoint!')
}
})
And I have 10 elements that have 'waypoint' class,how does waypoint plugin control if those elements are visible in viewport?Does it control all div's offsets every time onscroll event is triggered?
change the inverse scrolling behavior in ipad
I have implemented css scrollbar for ipad, as normally the scrollbar does not appear in ios. But now the scrolling behavior is different than that of windows, ie., we cannot hold the scrollbar and pull down ( as we do in windows ) so that the list goes down. Instead we swipe up on the scrollbar to do this. Any solution is highly appreated
Will the data in fwrite() buffer be cleared when a program exists abnormally?
fwrite() is a library call that firstly buffers the data into a user space buffer, and then call the write() system call later to actually carry out the write operations. If a program invokes fwrite() to write some data to a file but then exists abnormally, will the buffer of fwrite() be cleared, or the buffered data will be left over in memory?
Javascript string sorting functions
Hello I'm new to javascript and I'd like to know whether there are some sorting functions for working with strings since I haven't found any. Perhaps for alphabetical sorting like
var str = sort("bca");//str contains "abc"
If there aren't any do I have to just make my own or is there any other solution like importing them somehow?
x86 or amd64 Architecture?
I have compiled my application to using the x86 instruction set but I need to know programatically whether the machine the executable is running on supports the amd64 instruction set or not. Is there a simple way to find this out (possibly using CPUID)?
The application needs to be able to run on multiple OSes so non-OS based methods are preferred.
Adding ng-init code from json object
I'm trying to bind value of ng-init to a input from an json object.
However I get "Syntax Error: Token" where am I going wrong ?
$scope.obj = { init: 'obj.value = obj.value || 20' };
send textbox input on ng-click
I have an input and a button
<input type="text" name="search_tags" id="search_tags" placeholder="Search by Tags" class="form-control" >
<button type="submit" class="btn btn-primary btn-lg" ng-click="searchTags()">Search</button>
How do I pass the text present in the input textbox to the searchTags() function after button ng-click?
hide element press Esc
This code doesn't hide the box div
which was supposed to be hidden when I press the Esc key.
function Boxup(elementN, event){
$("#"+elementN).css({
"display":"block",
"top":event.pageY+"px" ,
"left":event.pageX+"px"
})
}
function hideCurrentPopup(ele){
$(ele).parent().hide();
}
$(this).keyup(function(event) {
if (event.which == 27) {
disablePopup();
}
});
Am I missing something?
How to create chain of processes in C?
I need to create 5 processes one being father of the second, grandpa of the third etc. All of them have to wait for each other to finish. I tried the approach with:
switch (pid = fork()) {
case 0:
printf("Child PID = %dn", getpid());
printf("parent: =%dn", getppid());
return 0;
default:
break;
But I always get the same parent.
AjaxForm success message from Php as json
Hi am new in using ajaxform plugin and I am passing a success or error message from Php as json and I can't access the messages. Please assist me on how to do it. Here is a sample of my code.
<?Php
$results['status'] = "error";
$results['status'] = "user not added";
header('Content-type: application/json');
echo json_encode($results);
?>
Learning PHP and web-programming for intermediate programmers [closed]
I would like to know some good resources (book or website) on learning PHP for those who are already familiar with programming.
Many of the tutorials I've been finding are for people who never programmed before and take way to long to go through to even learn basic language constructs.
The optimal resource would not assume previous web-development background however.
How to compile .c .h .so file?
Another company gives me three files(demo.c,api.h,libapi.so). they told me that't enough for develop. I'm confuse how to build these thing together. I use gcc demo.c -o demo -l libapi.so . But's it's said "ld: library not found". I use Mac OS system. Some websites said i should use Linux to use .so file. what should I do?
Set websocket origin to localhost javascript
I have server with doamin example.com. When user loads page on this server, it uses websocket client on javascrip to connect another websocket server. Another server uses CORS. So user can't connect to another server with websocket, becouse header Origin: example.com. But with Origin:localhost it can connect. Is it possible to set Origin: localhost when use javascript to connect with websocket?
How to generate a random number from within a range
This is a follow on from a previously posted question:
How to generate a random number in C?
I wish to be able to generate a random number from within a particular range, such as 1 to 6 to mimic the sides of a dice.
How would I go about doing this?
How to receive text from <div> tag?
I have a tag <div class="text9">
with text. I need to add this text in the title. For example: <div> for sale
. How can I do that?
I tried this, but it did not work:
preg_match('#<div class="text9">(.*?)</div>#isU'$text, $out);
Detect overlapping periods php
can you help me with overlapping periods. I have array
["1-9","11-15","14-20","8-11"]
Each element in array its period. Min - 1 period, max - 10 periods in array. I need to detect if they are overlapping.
I find this cases from another question
How many times does a number/character occurs in a string literal?
No tokenization should be necessary. Consider the following string literal:
char* string = "12, 789, 1234";
The output for this specific string would be:
0, 2, 2, 1, 1, 0, 0, 1, 1, 1
This means that there were 0 zeros, 2 ones, 2 twos, 1 three, etc.
I understand that I could use the ASCII table but I was wondering if there was an easier way of doing it.
How to put a final summary message in a yacc program?
When I redirect input to my yacc program from an input file, after it finishes parsing the file I want the yacc parser to print a summary of what it did. I want it to do the same thing if I am entering input through the keyboard and then I press Ctrl+D. Is there a way to do that?
Variable assignment in C vs scanf
I am new to C and I have a small problem in understanding this scanf()
line:
printf("Enter a message to add to message queue : ");
scanf("%[^n]",sbuf.mtext);
How do I write this statement if I am getting the value from the command line? I think I would have to declare the variable as a string?
Creating JSON-like data in Typescript
So in normal Javascript you can execute this block of code fine:
var myObj = {};
myObj['one'] = {};
console.log(myObj);
console.log(myObj.one);
But you get this error in TypeScript Property 'one' does not exist on type '{}'
Is this just by design? (e.g. I'm expected to make my own classes for this)
Should I reuse variables?
Let's say that i need a counter (I program in C), only once. Should I just reuse a variable that is no longer needed, instead of declaring a counter?
For instance:
int main() {
int in;
//code goes here
for(in=0; in<10; in++) //do something
//instead of using i, I reuse in and use it as a counter
return 0;
}
samedi 27 août 2016
How to delete multiple Ext components at the same time.-EXTJS
I'm trying to remove multiple elements from an array using EXTjs using id of the comp.
Ext.getCmp('id1').destroy();
However how can I do if i have to delete multiple comp ids, like:
Ext.getCmp('id3').destroy()
Ext.getCmp('id4').destroy()
Ext.getCmp('id5').destroy()
Any ideas?thx
Remove Number with Regex
i want to remove number at beginning and the end of word in one sentence for example:
"123helo helo123"
then it will return
"helo helo"
I've tried this pattern:
/^[0-9]|[0-9]$/
but it just recognized them as one string but not in words. Can you help me?
Set timezone for New Zealand
I'm currently developing a website using Laravel. I would like to change the timezone to New Zealand since it will be used there.
'timezone' => 'NZ',
I currently have that in my config/app.php and it returns the correct time but wrong am/pm. E.g time returned is 3:03 am, but correct time in new zealand is 3:03 pm.
How to dynamically allocate memory for JNI object array
I am working on JNI with C language. Here I have created an object array of size 4000. According to my requirements the array size has to grow dynamically. How can I allocate memory dynamically? I have tried using malloc
. But I cannot achieve this.
Here's what I have tried:
OriginalArray = (*env)->NewObjectArray(env, 4000, tradeObject, NULL);
default value of __PTRDIFF_TYPE__
I see it is legal to use the variable __PTRDIFF_TYPE__
with no header inclusion.
I tried to look for this variable name in ISO/IEC 9899
but it does not appear. I expected to see its definition in the 7th part, C library.
Why is it legal ?
I am using the gcc under Linux/GNU.
Valid json check in C language
I have searched a lot in google, I want to programatically check if the string below is valid json in C.How to do that? I am currently using json-c library.
char * string = "{
number1 : 100,
number2 : 10,
files : [ c , c++, java,PHP,java,PHP ],
random: [123567876523333,908,988]
}";
the library has no function to check if the string is valid json. Thanks in Advance.
how to get column names in PDO error?
when I use PDO errorInfo
I get this :
Array (
[0] => 23000
[1] => 1062
[2] => Duplicate entry 'zzz@zzz.net' for key 'email'
)
but I wanna get only column name > 'email' and 1062 for error code to echo :
this email zzz@zzz.net already registered
because I use email or phone or username for registration
A form's "action" and "onsubmit": Which executes first?
I'm trying to debug a webpage and I see a form element whose opening is
<form name="aspnetForm" method="post" action="default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
Having only a base knowledge of web form
s, I'm wondering what the order of execution is for the action
and onsubmit
.
HTML - Calling Javascript Function with variable? [on hold]
So I am trying to do a button and if you click on it then it calls a function called order()
. So, If I'm trying to do something like this order("+<script>blablabla</script>+")
then it shows me a error if I type into something between the "+HERE+"
Why that? Is there any way around it?
C Abstract Data Type in Rust
I have this code in my header file:
typedef struct _game* Game;
Right now to FFI from Rust I'm doing:
extern "C" {
pub type Game = usize;
}
Is there a safer way to do this than to treat it like a pointer-sized numeric type? Would this work:
pub struct Game(usize);
How to get input of the 4th child of an element using class?
<tr class='abc'>
<td></td>
<td></td>
<td></td>
<td>
<input></input>
</td>
<td></td>
</tr>
I want to when i click input of the 4th child of tr , alert something, what can i do?
Tell if HTTP request is Keep-Alive
How to tell if a HTTP request is a Keep-Alive connection?
Is it possible to detect via PHP if a HTTP request is Keep-Alive?
If a connection is not Keep-Alive I want to return an error as a part of the API protocol to reduce the use of resources at each SSL handshake and to speed up the communication between server and client
Why isn't my React code working?
I am getting this error on console, but I think the code is correct. https://s31.postimg.org/kyd70ejej/whats.png I have written the same code as told in this tutorial: https://egghead.io/lessons/react-introduction-to-properties. Can someone help? Thanks in advance :)
Radio Button with value to be <input type="text">
Is this possible to have input type="text" as a value to radio button ?
I have 3 options on the input type radio button.
[ o Option 1, o Option 2, o Others ]
But instead of adding Others, I wanted it to be an <input type="text">
wherein people can add in a specific value if they click this.
Value of each element in a form on the same page
we need help with listing names on one html page. So you as a user can submit more then one value in a form. The exact case is a form in which you type your names. Then the name has to be saved and listed underneath the form. So the users all can write there names and then all names will be listed underneath the form. Thanks.
cache with different url parameter
I'm reading that a url is cached based on the file AND parameter. I have a html file with some javascript that processes parameters that are passed in. I want to cache the file but if the parameter changes, then it has to load the entire file each time which defeats having a cache. How do I cache the file when the parameter changes all the time?
Where is the C auto keyword used?
In my college days I read about the auto
keyword and in the course of time I actually forgot what it is. It is defined as:
defines a local variable as having a local lifetime
I never found it is being used anywhere, is it really used and if so then where is it used and in which cases?
AngularJs creating dynamic form to generate JSON schema
I need to create a form, so that i can create custom JSON schema and save the schema into db using a service.
JSON schema will be like : {"id":"schema_id","name":"schema_name","data":[{"id":"id","type":"text","attribute":"abc"}, {"id":"id","type":"text","attribute":"xyz"}]}
Also i need to have conditions in the form if type is list or some other value.
Insert Into 3 Table Relational
how to input data through a table by using the checkbox, I have searched google and I have not found a way to it, I beg the help of the form as shown below to QUERY process. thanks
How to dispaly the three biggest numbers of one of the columns of a database table?
I have to write a php
script to find the three biggest numbers of a column in a database table. This is my code so far, but it doesn't work .
<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("pool");
$res1=mysql_query("SELECT * FROM buy ORDER BY value LIMIT 3 ");
while($r1=mysql_fetch_array($res1)){
echo $r1['value'];
}
?>
warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ using argv
I don't even know what is happening, I just started a new project and setup a basic cat just to make sure everything was working, and this happened.
#include "stdlib.h"
#include "stdio.h"
int main(int argc, char *argv) {
printf("%s",argv[0]);
return 0;
}
That's it, I reinstalled gcc, g++, and both multilibs. I really have no clue what to even think.
In C, can you do this? int i; i = get_long() % 20;
unsigned long get_long(); //returns some crazy large unsigned long
int i;
i = get_long() % 20;
The value of the right hand side should ALWAYS be big enough to fit into an integer because the possible values are only {0, 1, 2 .... 18, 19}.
Can I assume that the compiler can convert that unsigned long
right hand side to an integer on the left hand side?
how to parallelize this for-loop using reduction?
I am trying to make this for-loop parallelized by using Openmp, i recognized that there reduction in this loop so i added "#pragma omp parallel for reduction(+,ftab)",but it did not work and it gave me this error : error: user defined reduction not found for ‘ftab’.
#pragma omp parallel for reduction(+:ftab)
for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1];
change Linux users run time, from a c/c++ code
I want to change Linux users run time, from a c/c++ code. How could I do the same?
Lets say, I am running a c/c++ binary from a Linux user "abc" which is a non root user. Inside the c/c++ code I want to switch over to user a "xyz" to perform a specific task, and then regain the privileges of "abc" back.
vendredi 26 août 2016
Pass a trigger function to two components
Here is what i want to do:
render() {
return (
<div>
<Child onTrigger={xxx} />
<button onClick={xxx} />
</div>
)
}
When button
is clicked, I want something to happen in Child
. How do I do this? It cannot just be a boolean because it should be a trigger and be called multiple times.
multiple conditions for JavaScript .includes() method
just wondering, is there a way to add multiple conditions to a .includes method, for example:
var value = str.includes("hello", "hi", "howdy");
imagine the comma states "or" (it's asking now if the string contains hello hi or howdy. so only if one, and only one of the conditions is true.
is there a method of doing that?
Site got SQLi injected while using bind_param
Today I discovered my site got hacked through SQLi injection. Even though I am using bind_param I thought this was impossible.
if($_GET['api'] == 'info')
{
$status = 'Test';
$stmt = $mysqli->prepare("INSERT INTO information(one, two, status) VALUES (?,?,?)");
$stmt->bind_param('sss', $_GET['1'], $_POST['2'], $status);
$stmt->execute();
$stmt->close();
}
What am I doing wrong?
Chrome Dev Tools very slow to respond in large web app
I have a large, javascript heavy web app that I am working on. I am experiencing very slow response times from Chrome Dev Tools for XHR responses and console loggging (3-5 secs). The actual app is running fast and responsive, only dev tools looks like it is suffering.
Does anyone have any idea why Chrome Dev Tools is becoming sluggish as my app grows?
Script to Download Images From Multiple Web Pages
I would like to write a script that downloads images from a website. The website has a gallery of thumbnail images which link to a html page where the full resolution image is displayed.
How can I write a script that follows the link of the thumbnail, downloads the full resolution image, and repeats this process until all images are downloaded?
Thanks in advance!
put method doesn't update model in database nodejs
Have code without error in console, but field 'check' doesn't change on true state...why?
apiRoutes.put('/intake/:id', function(req, res) {
var id = req.params.id;
Intake.findById({id, function(err, intake) {
if (err)res.send(err);
check: true;
intake.save(function(err) {
if (err) {return res.json({success: false, msg: 'Error'});}
res.json({success: true, msg: 'Successful update check state.'});
});
}})
});
How to know the called program path in C/C++ in Linux?
I am having a compiled C program say test in /usr/bin and a python program say pgm.py is in /opt/python/ . In pgm.py , I am calling the C program like os.system("test arg1 arg2") . Is it possible for the C program to know that it is being called by /opt/python/pgm.py ?
Cannot read property 'childNodes' of null in a slider
I have created a simple Javascript slider with Slice and Box effects. It runs and no problem. But when i look up console, I see that after two cycles it throws an error. Browser says that document.getElementById('smth') cannot get specified element. What may be the problem? Below is codepen URL. Slider
script
ERROR: "Parsing WSDL: Couldn't load from" then do something
PHP preg_replace three times with three different patterns? right or wrong?
hey guys, simple question... Is this the best way to do it?
$pattern1 = "regexp1";
$pattern2 = "regexp2";
$pattern3 = "regexp3";
$content = preg_replace($pattern1, '', $content);
$content = preg_replace($pattern2, '', $content);
$content = preg_replace($pattern3, '', $content);
I have three search-patterns I want to filter out! Is my code above appropriate or is there a better way?
Thank you for the info
In Extjs, is it possible to whitelist allowed html tags for HtmlEditor?
As title states, I'm looking for a way to whitelist allowed HTML tags to be used in HtmlEditor in Ext.js. Looking at the document, nothing seems to pop up..
http://dev.sencha.com/deploy/ext-1.1.1/docs/output/Ext.form.HtmlEditor.html
Any ideas? Is it not supported?
Does gcc include some header files automatically?
I have the following code:
int main()
{
printf("Hellon");
return 0;
}
I compiled it using the following command:
gcc -o myprogram myfile.c
And it compiled without any error even though I did not #include <stdio.h>
. So did gcc include this header file automatically?
My gcc version is 4.3.3
Javascript prompt and submit
i want to get a value from JavaScript prompt and pass it to input for finally submit it
<form id="createdirForm"><input type="text" name="" id="createdir"/><form>
<script type="text/javascript">
function createdir(){
var newdirname;
newdirname = prompt('Please input the directory name:', '');
if (!newdirname) return;
$('createdir').newdirname.value = newdirname;
$('createdirForm').submit();
}
</script>
Need a regex for float values
I have a number field in the form and am validating that number field for float values. But I need to restrict the float number to only one period (.
)
For example:
122.00
But now its taking input like this also: 123.00.
.
I dont want allow another period (.
) in the end again.
Is there any regex for this?
How to know whether a pointer is in physical memory or it will trigger a Page Fault?
If I have a pointer and I care about memory access performance I may check whether the next operation on it will trigger a page fault. If it will, an algorithm could be designed so that it reorders loop operations to minimize page faults.
Is there any portable (or linux/windows non-portable) way to check for a particular memory address whether access will trigger a page fault?
undefined reference to 'xcb_event_get_label'
I have #included <xcb/xcb.h>
and <xcb/xcb_util.h>
and linked with -lxcb
but I still get an
undefined reference to 'xcb_event_get_label'
I can see the function exists in the header file, and the error indicates a linker error, but what other libraries do I need to link against?
for Repetition Statement in c
When for statement is executed the value of counter variable has to be increased by one because I use pre-increment operator.
#include <stdio.h>
int main (void)
{
unsigned int counter ;
for ( counter = 1; counter <= 10; ++counter /*here is problem*/) {
printf( "%un", counter );
}
}
Problem -
When the program is executed, the value of counter variable initially is 1 instead of 2.
Increment- Decrement Operator in c [duplicate]
This question already has an answer here:
#include<stdio.h>
int main()
{
int s=4;
int x=++s+++s;
printf("%d",x);
}
value of x?? Answer should be 12 but i am getting 11. Anyone please explain the concept.
how to pass values into array in javascript
I get values from php. In label values are like: a,b,c,d
and in amount = 10,20,30,40
var label= <?php echo json_encode($label ); ?>;
var amount= <?php echo json_encode($Amount ); ?>;
Now I want to combine these values like
{ x: "label", y: amount }
in javascript
how I can do this ?
Velocity.js fires off fadeOut but not fadeIn
I have the following code It should
if($(window).scrollTop()!=0){
console.log('doout');
$("#topbottom").velocity("fadeOut", { delay: 500, duration: 1500 });
}else{
console.log('doin');
$("#topbottom").velocity("fadeIn", { delay: 500, duration: 1500 });
}
}
It fires off the fadeOut on scroll however it won't fire off the fade in. It does write doin to the console when I get back to scroll zero...
A bit confused.
Thanks
Search a query that matches multiple table fields
How to retrieve / output values that match multiple table fields.
SELECT name FROM table WHERE name IN ( 'Value1', 'Value2' );
My search query should take the following parameters : first_name and roll_number in user_table.
e.g. Retrieving a query on the following lines : Roy whose roll number is 5
I need to query this using a single query.
Run a Batch File OnClick of Button from DOM in Node-Webkit App
I cannot seam to figure this out please help me run "run.cmd" onclick of button from my nwjs application.
<button onclick="runHelperProcess()">Run Process</button>
.
<script type="text/javascript">
function runHelperProcess() {
gui.Shell.openItem('run.cmd');
}
</script>
run.cmd is located in the root dir of the nw application.
IntelliJ 2016 how to create separate project to test PHP application
I have a project that is written in PHP with IntelliJ. I need to create a new IntelliJ project that contains only tests for the PHP application. I can't use classes from the application in the tests project. How can I add other project as a dependency for my project that contains the tests?
I have tried using IntelliJ module settings but I don't see the dependencies tab.
Trying to understand a program in C
I'm trying to understand this kind of program in C, but I can't. Exactly, I can't figure out how *s is changed, and why the compiler shows 210012.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void WhatIamDoing(char *s) {
char ch;
if (*s) {
ch = *s;
s++;
WhatIamDoing(s);
putchar(ch);
}
}
int main() {
char s[20] = "012" ;
WhatIamDoing(s) ;
printf( "%s", s ) ;
}
jeudi 25 août 2016
types and pointers address
Suppose the first element of double u[100]
has address 0x1000
, and sizeof(double)
is 8
. What does
printf("%p %pn", &u[3] - 1, &u[20] - 5)
output?
The homework answer is
echo '0x1010 0x1078'
How did they do the second part &u[20] - 5
?
How select data with given condition
I have following data.
{
"name" : "Maria",
"facebook" : [
{
"data" : "fb.com",
"privacy" : true
}
],
"twitter" : [
{
"data" : "twitter.com",
"privacy" : false
}
],
"google" : [
{
"data" : "google.com",
"privacy" : true
}
],
"phno" : [
{
"data" : "+1-1289741824124",
"privacy" : true
}
]
}
I want to return only data having privacy is equal to true. How do I do it ?
I tried but it returns all data having privacy is equal to false.
Thanks!
A web service for NFL schedules and scores (not api - json or xml)
I have been all over looking for a web service that supplies for free, of course, the NFL schedules/scores for 2016. Lots of answers; packages/fees/api's, but all I want is the service. Some suggested sites have disappeared or appear abandoned. What's being used out there in 2016? I prefer a json port but can deal with xml. I don't want to scrape.
Thank you for your help.
Mouse hover effect for owner drawn button without subclassing
As the title suggests, is there a way to receive in the parent window a notification of mouse hovering a button (which has been owner drawn) without the need of subclassing it? I use plain C on Windows.
I don't use custom drawing or any other types than owner draw (already tried).
I would like to change the appearance of the button when the mouse hovers it.
database creation using c programming
I want to create database using C programming.
I want to create the employee database system and want to update it dynamically. please guide me how can I go ahead.
I have to do it for embedded system which as flash memory. the database is need to be stored on that flash and I need to be able to update it dynamically. Document and suggestions are valuable.
Class 't3lib_cache_backend_FileBackend' not found
After updating TYPO3 from 4.5 to 7.6 and a PHP update from 5.3 to 5.5 I get this error in the install tool:
Detected Fatal Error
Class 't3lib_cache_backend_FileBackend' not found in /var/www/htdocs/typo3src/typo3_src-7.6.9/typo3/sysext/core/Classes/Cache/CacheFactory.php on line 76
PHP-Version is 5.5.36. A new download of the TYPO3 src did not solve it.
JavaScript library for offline maps?
I want a JavaScript offline library for world maps that allows me to provide a city name and then locate it on the map(using lat and long that is stored in it).
I've come across amchart maps, leaflet and jVectorMap but none of them has this offline support I want. Google Maps also doesn't provide this offline support.
Can you name some JS libraries for this ?
JavaScript ES6 - ERROR: You can only use decorators on an export when exporting a class
I am trying to export a function in ES6 so I can import it and use it in other files to have a DRY code. However I receive the following error:
You can only use decorators on an export when exporting a class (16:0) while parsing file:
export function totalItems() {
this.cart.items.forEach((dish) => total += item.qty);
return total;
}
Any ideas?
Javascript Send Enter Key after alert
I want to send Enter key with javascript after alert.I try this code:
setTimeOut(function(){
$(document).trigger(13);
},3000);
But this is not working. How do I do this?
image:
http://i.stack.imgur.com/VNYKo.png
I want to send Enter key on alert
How To Display Color Swatches In Product Page Magento
I want to display the color swatches on the magento product page . I have tried from magento admin panel by changing the configuration settings in the system but it is not working
any help would be appreciated !
Portable AES CFB Mode in C
I'm searching for a portable Version of AES 128bit CFB in C to include into my programm without a needed libary. It is used to crypt and encrypt strings sent over sockets so its just needed for plain text. It would be nice if there is a implementation with a little tutorial out there (Searched already for about 4 hours without success) Kindest regards John
Custom PHP Error Page for NGINX Not Responding To '?=_'
I've recently created a custom error page with configuration such as:
error_page 404 /error.php?code=404
But it seems to show up only error.php
instead of error.php?code=404
.
I've cheked the php file by accessing /error.php?code=404
in my browser and it works fine. I am using $Get
Please help. Thanks a lot.
find elements which id contains two substrings
I have an HTML table and I need to change the CSS style to all de <td>
whose "id"
contains the substring "_A_189"
and the substring "_B_V_852"
using jquery. The substrings could be in any position of the string.
I use this, but it doen't work:
$('id:contains("_A_189"):contains("_B_V_852")').css(style);
How can i check if shape:[] is null in json with php
I have a json object like this :
{"Techne":{"@Version":"2.2","Author":"ZeuX","Name":"","PreviewImage":"","ProjectName":"","ProjectType":"","Description":"","DateCreated":"","Models":[{"Model":{"GlScale":"1,1,1","Name":"","TextureSize":"1,1","@texture":"texture.png","BaseClass":"ModelBase","Geometry":{"Folder":[],"Shape":[],"Piece":[],"Null":[]}}}]}}
How can I check if the array Shape:[] is empty with PHP I only know how to do it with JavaScript but this matter needs PHP to be used how can I do it?
using float data type inC [duplicate]
This question already has an answer here:
- Is floating point math broken? 26 answers
include
int main(void)
{
float x=0.1;
if( x == 0.1)
printf("truen");
else
printf("falsen");
}
//I expect an output "true" but getting output "false", can anyone explain what's happening and give a solution
What is mysql password
i was trying to import a large database (only 6.26MB) into phpmyadmin using cmd. After writing the syntax of importing the database, i've been asked to enter the password. My phpmyadmin or mysql has no password from what i know.Screenshot of the syntax attached
Can you help me to tell me which password i'm asked to enter ?
Search value "in_array"
I have this array
Array
(
[result] => Array
(
[status] => nok
[reason] => Character not found.
)
[code] => 404
[content_type] => application/json;charset=utf-8
)
I want to check the [status], if it is "nok" it should appear "Match found".
My code:
$info = $r['result']['status'];
if (in_array("nok", $info))
{
echo "Match found";
}
else
{
echo "Match not found";
}
?>
preg_replace_callback(): Requires argument 2 to be a valid callback in
$ent_check = empty($modSettings['disableEntityCheck']) ? array('preg_replace_callback('~(&#(d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$func[\'entity_fix\'](\'\2\')', ', ')') : array('', '');
Warning: preg_replace_callback(): Requires argument 2, '$func['entity_fix']('2')', to be a valid callback in
I'm not quite sure what to do here. Any help from someone smarter than I would be greatly appreciated...
Cannot access outside of domian folder using __DIR__
while I was using __DIR__ . '/../folder/outside_of_domain_folder/file.inc.php
to access a file outside of my domain folder, an error was returned (no such file or directory)
but the file does exist. But when I used it access a include file within my domain folder, __DIR__
works again. Any reasons why this happened? Or did I made some mistake in my code?
Check whether an array exists in an array of arrays?
I'm using JavaScript, and would like to check whether an array exists in an array of arrays.
Here is my code, along with the return values:
var myArr = [1,3];
var prizes = [[1,3],[1,4]];
prizes.indexOf(myArr);
-1
Why?
It's the same in jQuery:
$.inArray(myArr, prizes);
-1
Why is this returning -1 when the element is present in the array?
Primality test using Fermat little theorm
code:
void prime()
{
int i,N;
scanf("%d",&N);
for(i=2;i<N;i++)
{
if (((i^(N-1))%N )==1);
else{
printf("not prime");
return;
}
}
printf("prime");
return;
}
This program is based on Fermat's Theorem on prime numbers. N is number to be tested as prime. This program is not showing correct result for '11'. Maybe due to some mistake which is not identified by me.
Spaces inserted by the C preprocessor
Suppose we are given this input C code:
#define Y 20
#define A(x) (10+x+Y)
A(A(40))
gcc -E
outputs like that (10+(10+40 +20)+20)
.
gcc -E -traditional-cpp
outputs like that (10+(10+40+20)+20)
.
Why the default cpp inserts the space after 40
?
Where can I find the most detailed specification of the cpp that covers that logic ?
Undefined index: email in C:xampphtdocsweb-exploit-examples-masterevil-orgevil01.php on line 2 [duplicate]
This question already has an answer here:
$email = $_GET["email"];
$password = $_GET["password"];
if ($password) {
$db = mysqli_connect("localhost:3306","root","","");
$query = "INSERT INTO stolen_accounts (`email`, `password`)
VALUES ('{$email}', '{$password}')";
mysqli_query($db, $query);
}
Fetching status code description with jquery
I'm attempting to fetch status code description I send from asp.net mvc app via jquery and ajax, but can't seem to find where it's hidden.
This is backend:
return new HttpStatusCodeResult(403, "someDescription");
and this is jquery:
$.ajax({
url: someUrl,
method: "POST",
data: "teamMemberId=" + id,
statusCode: {
404: function (obj, textStatus, errorThrown) {
cancel();
},
403: function (obj, textStatus, errorThrown) {
alert(
//statusCodeDescription
);
},
200: cancel
}
});
Thanks!
mercredi 24 août 2016
Javascript - removing undefined fields from an object
Is there a clean way to remove undefined fields from an object?
i.e.
> var obj = { a: 1, b: undefined, c: 3 }
> removeUndefined(obj)
{ a: 1, c: 3 }
I came across two solutions:
_.each(query, function removeUndefined(value, key) {
if (_.isUndefined(value)) {
delete query[key];
}
});
or:
_.omit(obj, _.filter(_.keys(obj), function(key) { return _.isUndefined(obj[key]) }))
Where is the Trash directory?
The trash spec tells me that the Trash directory is here: $XDG_DATA_HOME/Trash
Looking at my environment variables on my Linux Mint system, I find a bunch of XDG stuff, but no XDG_DATA_HOME
I've done some looking, but so far I have not been able to locate the Trash directory. Where is it?
How to change the default action of the index controller zend
I have just created a new Zend project. I want to use the setDefaultAction
to change the default action of the Index controller to any other action of the Index controller. I know that I need to code something like :
$front = Zend_Controller_Front::getInstance();
$front->setDefaultAction("about");
but in what function I need to code this? Do I need to do something else?
JavaScript: requestAnimateFrame get faster
I have an animation with requesetAnimationFrame And when I replay it, it gets faster and faster until it gets invisible.
function tirer(){
var missile=document.getElementById("missile");
var currt= missile.currentStyle ||window.getComputedStyle(missile);
if ( parseInt(currt.bottom)<700)
missile.style.bottom=parseInt(missile.style.bottom)+20+"px";
else
alert ( "in top");
}
function animation (){
tirer();
requestAnimationFrame(animation);
}
How can I get it to be a stable, constant speed?
passing url parameters in angular
I'm trying to pass some url parameter between view to get the detail of a particular user but i'm finding it hard to do
.controller('profile_detail_ctrl',['$scope','$http','$state',function($scope,$http,$state){
$http.get('http://localhost/myapp/app_ion/templates/profile/profile.php?profile_id='+$scope.profile_detail).success(function(data){
$scope.profile_detail=data;
$scope.profile_id=$state.params.profile_id;
});
Centered (h&v) 16:9 iframe that uses as much screen estate as possible but refrains from being cropped anywhere
Requirements:
HTML:
<div class="container">
<iframe></iframe>
</div>
CSS:
.container {
width:90vw;
height:50vh;
}
Now if I resize the browser (vertically OR horizontally) the video should not be cropped and no scrollbars should appear.
How to achieve this?
static html page in CakePHP
I have a static html page in cakePHP application which I want to link in my route.php file.
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'index']);
It uses the controller file and adds header, footer, css, JS, etc to the index.ctp
but how can I have the page as it is without adding code or using any controller? (like linking to static html page).
Work with content wrapped with Scrolloverflow.js + Fullpage.js
I use Fullpage.js together with Scrolloverflow plugin for my template:
$('#fullpage').fullpage({
scrollOverflow: true,
afterRender: function() {
$("nav").on("click", "a", function() {
...
}
}
});
On the official website they say that I need to use delegation in order to work with content wrapped by the Scrolloverflow plugin. However, it doesn't seem to work in my case, because the click
event doesn't work in my example. Any ideas?
How can i use idUser in a password_resets (laravel 5.2)
I want to use the table password_resets that I obtained with the comand php artisan make:auth, but this table use the "email" and this is not right because if my users change their email in their profile then is a problem to identify them, i want to use the "idUser" in the table "password_resets" instead of "email".
Where can i change this in the code????
Gulp: How do I read file content into a variable?
I have a gulp task that needs to read a file into a variable, and then use its content as input for a different function that runs on the files in the pipe. How do I do that?
Example psuedo-psuedo-code
gulp.task('doSometing', function() {
var fileContent=getFileContent("path/to/file.something"); //How?
return gulp.src(dirs.src + '/templates/*.html')
.pipe(myFunction(fileContent))
.pipe(gulp.dest('destination/path));
});
Unable to load dynamic library php_pdo_oci.dll%1 is not a valid win32 application - phpstorm
I'm trying to load the phppdo_oci.dll lib to interact with my oracle database on my website, but I can't load it because of this error:
A PHP Error was encountered
Severity: Core Warning
Message: PHP Startup: Unable to load dynamic library 'C:phpextphp_pdo_oci.dll' - %1 n�est pas une application Win32 valide.
Filename: Unknown
Line Number: 0
Backtrace:
I'm using phpstorm and php 5.6.22
amazon s3 php HTTP ERROR 500
use Awss3S3Client;
require dirname(__FILE__).'/vendor/autoload.php';
$config = require dirname(__FILE__).'/config.php';
On localhost
it works well but in my remote hosting I'm getting HTTP ERROR 500
.
I think the problem is in this part of the code:
$s3 = S3Client::factory([
'key' => $config['s3'] ['key'],
'secret' => $config['s3'] ['secret']
]);
How to display product price with and without tax at a time in product list for Prestashop?
In the product list I need to display the product price with and without tax at a time.
I am using the version 1.6 of Prestashop.
Right now the price including tax is displayed in the product list. I want to display the price excluding tax as well.
How can I do that? I have searched for solution and was not able to find a working solution for me.
Hide chart labels
I'm using chartjs and I can't hide the labels that show in top of every pie chart. Ex:
And I cannot hide those labels, like AK47, AUG, etc. How can I do it? Thanks!
JQuery UI MultiSelect plugin for a dropdown checkbox menu
I have been trying to use the jQuery UI MultiSelect, found here: http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos for some time now, but I have been unable to install it. I've searched the web and I haven't found any tutorials on how to do so. I would like to install the plugin and use it to dynamically create a dropdown checkbox menu.
NGINX only serves php files
So I was messing around on my Ubuntu server, and now the only files that can be served are .php ones. Anything else results in a 502 Bad Gateway Error. I am running NGINX and PHP5-fpm. Any ideas what could be going wrong? I have not messed with any conf files, so I think this may be a permissions or ownership problem. I am an amateur at this stuff, so any help would be appreciated.
Telegram add member to channel by bot api
I have seen this question, but unfortunately no one answered:
How to add user to my telegram channel by telegram api?
I have created a bot and a channel in telegram. Then I added the bot to channel's administrators. How can I add members to channel by my bot APIs?!
Programming languages: PHP, Python, C++:Qt, Java, C# (every of them or any library)
How can I get the URL address from the browser in ReactJS (servers URL)
I can parse are HTTP response of one of the intial calls and save that in the state but there must be another way to get the URL?
I am using the npm 'rest' library and want to specify a different port but I do not know the path on which machine the server will be installed so I need the server's url.
Solution
window.location.hostname
How can I benchmark C code easily?
Is there a simple library to benchmark the time it takes to execute a portion of C code? What I want is something like:
int main(){
benchmarkBegin(0);
//Do work
double elapsedMS = benchmarkEnd(0);
benchmarkBegin(1)
//Do some more work
double elapsedMS2 = benchmarkEnd(1);
double speedup = benchmarkSpeedup(elapsedMS, elapsedMS2); //Calculates relative speedup
}
It would also be great if the library let you do many runs, averaging them and calculating the variance in timing!
Does Backbone.sync have any actual logic?
Usually I think of synchronization as looking at two sources and then making sure they are the same after a sync.
But looking at the backbone code, it looks like a sync is actually a save in some cases. It simply saves data on the client to the persistence layer.
Is this correct?
Google maps javascript DirectionRenderers limit
I am looking to display many routes on one instance of map, each route with different color. For it I created an array of DirectionsRenderer objects and assigning separate DirectionsRenderer for each route. The problem is GoogleMap component displays only first 10 DirectionsRenderer, I was not able to find any info on this limitation in google developers website. Is there any way to use more than 10 DirectionsRenderers at same time?
Thanks for help in advance.
No alive nodes found in your cluster - ElasticSearch
i'm using this package on laravel 5.1
but i see this error alltimes:
NoNodesAvailableException in
C:xampp...vendorelasticsearchelasticsearchsrcElasticsearchConnectionPoolStaticNoPingConnectionPool.php line 51:
No alive nodes found in your cluster
'hosts' => ['127.0.0.1:9200']
can you help me?
i'm newbie in elasticsearch
Replace all elements with specific tag with a component
Is it possible ?
Basically what i would like to do is on a event like clicking an 'edit' button i need to replace all elements with a specific tag with an input field i know how to do it with jQuery but would prefer doing it with react.
jQuery/Pseudo Code:
$('a').each(function(e,i){
e.html('<input placeholder="'+ e.text() +'" />');
});
Drupal 8 - Cannot open source device in random_bytes() + core/lib/Drupal/Component/Utility/Crypt.php
I've problem to install Drupal 8.1.3
in my Mac OSX El captain :
My development environment :
PHP v7.0.9, Zend Server
Problem :
The website encountered an unexpected error. Please try again later. Exception: Cannot open source device in random_bytes() (line 31 of core/lib/Drupal/Component/Utility/Crypt.php).
It would be highly appreciated if someone can point me in the right direction.
Why is func undefined in this context?
So I have a function like
func()
{
const curVal = this.curVal;
const callAgain = () => { func(); };
Axios.get('somecontroller/someaction')
.then(response =>
{
const newVal = response.data.curVal;
if(curVal === newVal)
setTimeout(callAgain, 500);
else
// ....
})
.catch(response =>
{
// ...
});
}
and my browser is complaining about the line
const callAgain = () => { func(); };
saying that func
is undefined
. Any idea why? How can I fix?
mardi 23 août 2016
change key/values of an object
If I have a result like this:
result = [
{ '0': 'grade', A: 'name', b1: 'number' },
{ '1': 'grade', B: 'name', b2: 'number' },
{ '2': 'grade', C: 'name', b3: 'number' }
];
How can I produce :
result = [
{ A: '0', b1: '0' },
{ B: '1', b2: '1' },
{ C: '2', b3: '1' }
];
I want to pass the analogous grade instead of name and number.
Plugin working in Wamp but not online
I downloaded a file (lobibox a notification plugin) wich i use in my offline website (WAMP) just fine; but doesn't work on my officiel website...
I made sure all of the files and paths were correct .
For some reason the plugin will not work on my website but works fine on other websites and works fine on my localhost...
Can anybody tell why this is ? and what I should do ?
es2015: converting to es2015 with arrow function
Consider I have this:
mongoose.connection.on('error', function (err) {
if (err) {
throw err;
}
});
How do I convert this to ES2015 syntax?
I tried:
export class MongooseConnectionUtil extends MongooseUtil {
constructor(...args) {
super(...args);
this.connection = mongoose.connection;
}
on('error', err) => err {
if (err) {
throw err;
}
}
also tried with the ()
on('error', ()) => err {
if (err) {
throw err;
}
}
Looping through all the images on a page
2 Questions:
What will be the most officiant way to loop through all of the Images on a given page and open each one in a new tab.
Same idea but instead open in a new tab I would like to push different images instead of the given ones. The idea is to build a widget that will inject cat photos instead of the normal photos of websites.
Jquery - Duplicate span price value to form input without euro sign or comma
I have a price span and need to duplicate its numerical value into a form input without the euro sign or comma.
The code is
<span class="main-price">€25,960</span>
<input id="fieldname2_1" class="field number small valid" type="number" value="20000" max="100000" min="0" name="fieldname2_1">
And I need the number only so clone over 25960.
How would I do this in jquery?
PHPMyAdmin search not finding text?
I want to search and replace our old domain, example.net
, to example.com
in our MySQL database.
When I try to search in the database using PHPMyAdmin, It returns 0 matching records
, but when I downloaded the database to my local computer and opened it using Notepad++, I found more than 1000 matches searching for the old domain (example.net
).
How is it possible?
Ignore empty match php Regex
I need to replace all of the text within the tag (which is not a code). So I'm using:
preg_replace('/<.*?>([^<]*)</.*?>/', "new_text", $str)
And I get a result. But I need to remove all empty and onlywhitespace matches or eliminate them from the search. How can i do it?
How to Separate Columns in a txt file , So that I can search for a specific column by typing the column header in command prompt
I have a input.txt file that has columns. I was thinking to create N amount of arrays(N = amount of columns in file) and store each word (char) into an array while increment after each insertion. Then map arrays 1 to N to the according column headers. Any advice/tips on how to implement this or different ways to do it will be appreciated.
PS. My first question so I hope it is clear enough.
How to show error message on previous page?
I want to show an error on the same as page as my form. My form is going to another page and then processing and returning the result. How can I show the error on the previous page?
if($_POST['btnManage']=="Signup"){
$objCustomer->Email=$_POST['txtEmail'];
$objCustomer->Password=$_POST['txtPassword'];
$Status=$objCustomer->Signup();
if($Status>0)
{
session_start();
$_SESSION['Email']=$objCustomer->Email;
header("Location:../index.php");
} else
{
echo "error";
}
}
What is an Associative Array? [on hold]
QUESTION:
What is an Associative Array?
ELABORATING ON QUESTION:
The syntax I see when searching an Associative Array is as follows:
$myArray = array(
"car" => "truck",
"price" => 50000
);
and I would love to know what the structure of the array does, the purpose of an Associative Array, and some examples so that I can have a complete understanding for future use.
Is there anyway to add an ng-click to md-backdrop?
I have an angular app that needs to switch states when a sidenav is opened or closed. This works fine when opening the sidenav and closing it via a close button. However I need to attach an ng-click to the md-backdrop in the event that the user closes the sidenav by clicking outside the sidenav. Has anyone else had this issue or does anyone have an idea on how to achieve this? Any help would be greatly appreciated.
Finding out my User Agent on Node Weblit
When using browser context in Node-Webkit, is there any way to find out what is the exact User Agent used for external requests, from within Node-Webkit?
Example: if Node-Webkit loads an image that's in an HTML from some remote, I would like to know what's the User Agent this remote will see.
Using a sniffer (Fiddler/Wireshark) is trivial, but I'm looking for a method to obtain this information directly.
Thank you.
Purpose of LDA argument in BLAS dgemm?
The Fortran reference implementation documentation states:
* LDA - INTEGER.
* On entry, LDA specifies the first dimension of A as declared
* in the calling (sub) program. When TRANSA = 'N' or 'n' then
* LDA must be at least max( 1, m ), otherwise LDA must be at
* least max( 1, k ).
* Unchanged on exit.
However, given m and k shouldn't I be able to derive LDA? When is LDA permitted to be bigger than n (or k)?
How to set path to non-standard installation of Firefox browser in Selenium Webdriver JS on Win7
I am currently instantiating webdriver as follows.
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('firefox').build();
I understand that webdriver will look for firefox in the standard Windows install location. How can I specify that webdriver use firefox in a non standard location, such as a portable app installed in a folder on the desktop for instance. I've seen some answers in python, but none for node.js. Thanks!
Drawbacks of increasing PHP memory limit
Recently my app started throwing fatal errors regarding exhaustion of the max allowed memory. After some research, I found out that the limit is set in the .htaccess
file and it sets to 64m.
The tried allocation is of around 80MB, and we are able to provide these resources, but I wanted to ask the community if increasing the value of this variable is a good solution to the problem. Thank you very much
Understand confusingly similar javascript code snippets
Here, there are two different code snippets. I need to know what the output of each is, and why it produces that output.
var output = (function(x){
delete x;
return x;
})(0);
console.log(output);
var x = 1;
var output = (function(){
delete x;
return x;
})();
console.log(output);
sort results of array count values into a new array
I want to sort the results to a new array but without the $key so the most UNunique number will be first (or the most duplicated number will be first).
<?php
$a = array (1,1,2,2,2,3,3,3,3,4,4,4,4,4,5);
foreach (array_count_values($a) as $key => $value) {
echo $key.' - '.$value.'<br>';
}
//I am expecting to get the most duplicated number FIRST (without the $key)
//so in that case :
// $newarray = array(4,3,2,1,5);
?>
Cannot send session cookie - headers already sent PHPUnit / Laravel
I have this strange problem when i call the parent::setUp()
on my TestCase class for unit test a class
when i run phpunit it throw me this error:
1) MatchRequestRepositoryTest::test_find_requests_by_match_id ErrorException: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/project.dev/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:459)
What can be the problem? Thanks for any help.
angular - how to call http request from an iframe
I have index.html file that recognize my whole app (flask app) and this index.html has an iframe that point to indexApp.html that in "static" folder. in indexApp.html i initiate my angular app so now my app see only files that inside "static" folder, so http request cant working (work on "views.py" file outside static folder) i cant change the hierarchy of the files (put "views" in static folder).
what should id do?
How do I create a customer on stripe without enter card information
there I would like to create a customer on stripe without the user entering their card information to begin with. When a user signs-up to my website, i would like them to also have an account created with stripe. I want information such as address to be stored on stripe from signing up on my website. So when the user does want to purchase an item the information can then be retrieved from stripe. How can I do this.
How to link uClibc against libgcc.so1?
I want to build uclibc linked to libgcc.so1 I don't know weather I need to activate some option in .config file or something else. For now in case of running software on ARM machine when a function from uclibc is called which calls some libgcc.so1 function I get linker error.
I tried to deassembly libuclibc.so and in symbol table I found that all functions from libgcc.so1 are undefined and they addresses are 0's
not able to send arabic email with good caracters
i want to send an arabic email with using php , but it gives me others caracters , how to send it with the arabic caracters ? this is my code :
$subject = $_POST['subject'];
$message = $_POST['message'] . "nn" . 'Regards, ' . $_POST['name'] . '.';
$headers = 'From: ' . $_POST['name'] . "rn" . 'Reply-To: ' . $_POST['email'] . "rn" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
if( $_POST['copy'] == 'on' )
{
mail($_POST['email'], $subject, $message, $headers);
}
}
?>
Clear input with protractor non-angular syntax
I am testing a non-angular (javascript and HTML) site with protractor and selenium. I want to clear the input. I have used below commands
browser.driver.findElement(by.id('txtname')).clear();
browser.driver.findElement(by.id('txtEditGuestFname')).sendKeys(Keys.chord(Keys.CONTROL, "a"), "1234");
since i can not use angular syntax both the codes doesn't work to me.
Any other idea how to clear the input with simple javascript protractor supporting code?
Import .obj files and textures on Glut in C
We are making an OpenGL project in C using the Glut Library. We wanna import an .obj file and apply texture to it (the model already comes withe the textures files). So far, we have imported the .obj model with success, but its just a lot of points. How can we apply texture to it? Is there any library that could help us import the model and the textures, and make a little more easy to work with them?
lundi 22 août 2016
CodeIgniter - how to send email using wamp server? without provide sender email
I am using CodeIgniter and wamp server. I tried to send an email with Gmail email sender, I have got a successfully received email. Using email library.
$this->load->library('email');
But now I need to send email without show sender email, e. i. from the localhost server just provide name of sender without email.
How to send email using localhost mail server without providing an explicit sender email.
WooCommerce category page layout [on hold]
My site has only 3 categories and I want to list them like this to fill the shop page, but products to remain in grid layout.
My woocommerce structure is: in my theme folder I made a woocommerce.php and a woocommerce folder with templates files from plugin directory Templates. I cannot make changes in my mytheme/woocommerce/archive-product.php because mytheme/woocommerce.php has priority over.
How to get Javascript variable from an HTML page?
In the source code of a page on the internet, there is a Javascript variable containing JSON data that I would like to store in a variable in my PHP program.
Any idea about how to do it?
The file is on a public html link and it looks like this:
<script type="text/javascript">
var serializedForm = {"fields": ... } ;
</script>
Thank you for your time and answers :).
In compilation time how to find the macro is defined in which header file
Lets take the below code , If the macro HAVE_SYS_SELECT_H is defined then they included the header file. I need to know where the macro is ? That is in which which header file the macro is defined.
Is there any option for that while compiling the source code ?
Is there is a way to find the header file ?
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
Php Regular Expression /^d{10}$/;
Am trying to update a PHP script which has this code:
function CheckNumber(MyNumber)
{
var MN = /^d{10}$/;
if (MN.test(MyNumber)) {
return true;
}
return false;
}
I think the script above force entry of 10 digits. nothing less and nothing more.
I need to fix it with the condition - not more than 12 digits - also allows less than 12 digits. - no special characters.
Please help. I don't understand regular expression codings.
PHP Mysql timestamp wrong format
ive got this in as my php-code on 2 sides:
date_default_timezone_set("Europe/Berlin");
$time_stamp = date('Y-m-d h:i:sa');
i insert the value at the first page, and at the second i update the join_timestamp. But the time-formats are diffrent idk why.
Laravel - display a PDF file in storage without forcing download?
I have a PDF file stored in app/storage/, and I want authenticated users to be able to view this file. I know that I can make them download it using
return Response::download($path, $filename, $headers);
but I was wondering if there is a way to make them view the file directly in the browser, for example when they are using Google Chrome with the built-in PDF viewer. Any help will be appreciated!
How to pass parameters from PHP file to Javascript
I have my file hotlaps.php
where I have created a script of javascript with:
echo "<body onload="func1(".$array_1.",".$array_2.",".$array_3.");">";
In my file hotlaps.js
I have that function:
function func1(array1, array2, array3){
arr1 = array1;
arr2 = array2;
arr3 = array3;
alert(piloto_array[0]);
start();
}
But my variables arr1
, arr2
and arr3
are undefined. Why?
Finding elements by scroll
Hey is it possible to find any elements on scroll page? For example: We have div's with classes named 'blocks'. Now if I scroll page I want to do some stuff if scroll top detect one of each classes named 'blocks'. And as result should be this class named 'block'.
I really dont have idea for this. Anyone looking for scroll bot or specific 'id' then i couldn't find answer for this question.
Thanks for help!
Does the Wordpress initialization scripts run every time a request hits the server?
The index.php
file in my Wordpress installation directory seems to run several other scripts in order to properly configure the Wordpress Environment, and in turn, these scripts define several constants. My question is: does that procedure of running the initialization scripts and defining constants happens every time a requests hits the server, or does it happens only after the first request to the server and these environment constants and settings remain defined until the server is shutdown?
JavaScript showing active div when scroll the page
I searched almost everywhere but I couldn't find it. I have a feed like facebook or instagram. I put the advirtesment div after every 5 posts like other posts(like on instagram). The problem is that when I scroll the page if scroll position is at the advirtesment div I want to add a class like in-view with js. How can I do that? By the way, I load other posts when scroll is bottom of page. Thank you in advance
array formating in php
I have an array ->
Array (
[0] => Array
(
[ID] => 3
[TotalCost] => 0.00
[Name] => Tim
)
[1] => Array
(
[ID] => 1
[TotalCost] => 19.99
[Name] => Chris
)
)
In php, I want to change it to ->
Array (
[Tim] => Array
(
[ID] => 3
[TotalCost] => 0.00
)
[Chris] => Array
(
[ID] => 1
[TotalCost] => 19.99
)
)
I tried few things but not getting desired result. Please help.
How to display password item in a wordpress page?
Does anybody know how to do this? 1.The current user is already registered and logined; 2.I need a page to display a password item and repeat password item for current user so that could let they change their password,like wordpress itself profile option,but display in a page:
Password*
[________________] <-input area
Repeat Password*
[________________] <-input area
PHP mail() not sending GMAIL
I created an AJAX that sends via POST some user input data to a PHP file which validates it and then sends it to my personal email (Gmail). I was doing some tests with fake emails and everything was working right but when I tried to use an existent gmail the message never delivered. Do you guys have any idea what is going on? Thanks in advance and sorry if I spelled something wrong, I am not a native English speaker.
PHP mail() not sending GMAIL's
I created an AJAX that sends via POST some user input data to a PHP file which validates it and then sends it to my personal email (Gmail). I was doing some tests with fake emails and everything was working right but when I tried to use an existent gmail the message never delivered. Do you guys have any idea what is going on? Thanks in advance and sorry if I spelled something wrong, I am not a native English speaker.
JavaScript filter array function
I've made a list of ships that it represented like so:
var fleet =
["RMS MARY", 2000, 15],
["TITANIC 2", 10000, 13],
["Boaty McBoatface", 2000, 18],
["Jutlandia", 1945, 10],
["Hjejlen", 250, 8]
];
I want to write a function that will filter the ships by a given capacity. Example:
filterByCapacity(fleet,5000)
This should only return the ship Titanic 2
since it is the only ship with a capacity higher than 5000
.
Any ideas on how to write such a function?
get javascript variable value in jsp scriptlet [duplicate]
This question already has an answer here:
I have a scenario where i need to compare javascript varibable with java object inside scriptlet of jsp page. How can i get javascript variable in the jsp scriptlet or the other way will also work for me(getting arraylist object value in javascript).
Detect if parameter passed is an array? Javascript [duplicate]
Possible Duplicate:
How to detect if a variable is an array
I have a simple question:
How do I detect if a parameter passed to my javascript function is an array? I don't believe that I can test:
if (typeof paramThatCouldBeArray == 'array')
So is it possible?
How would I do it?
Thanks in advance.
Typecasting character pointer to an integer pointer
#include <stdio.h>
int main()
{
int a[3]={2,3,4};
char *p=a;
printf("%d ",*p);
p=(int *)(p+1);//What does this statement do ?
printf("%d",*p); //Will the pointer extract 2 bytes(16 bit compiler)or1?
return 0;
}
I'm getting output as 2 0 . I understood why the first printf is printing 2 but not understanding why 0 in the next printf ? Is it that if I want to jump so many bytes away then I should a pointer of that many bytes long ?
Any sort of PHP script that searches directory for names of files? [on hold]
I am trying to get a sort of search engine type thing that searches for names of files based on what a user posts, and then displays all related searches+links to them.
I have tried this:
var str = "";
var n = search("files/");
And I have no idea how JavaScript works. I want some sort of PHP script to do this.
Please, no database if possible (but i can deal with it).
Javascript constructor called with extra param: 'this'?
I have one js
file calling an object's constructor but with an additional parameter (this
) pre-pended to the argument list. I'm guessing this has something to do with the inheritance but I just don't know. (My background is Java.)
index.js
var AlexaSkill = require('./AlexaSkill');
var Josephine = function () {
AlexaSkill.call(this, APP_ID);
};
AlexaSkill.js
function AlexaSkill(appId) {
this._appId = appId;
}
How to send session request with cookies via curl?
I want to send a request using curl for session and cookie to a URL on my server. But click can't be counted.
http://requestsite.com/sessionverify.php
And sessionverify.php redirects to a URL which updates the request. The redirect URL of sessionverify.php is http://requestsite.com/click.php
How do I do this?
'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied [LARAVEL]
I'm doing some records to the database and from time to time came out this error:
local.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000]
[1045] Access denied for user 'homestead'@'localhost'
(using password: YES)' in
:WEBlitraenvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:55
I have the file env. properly configured.
env.
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=auth
DB_USERNAME=root
DB_PASSWORD=
How to make my navigation bar scale up when resizing browser window
Does anyone know how can I make my navigation bar scale up like this when I resize my window? (look at this website below to see how the navigation menu scales up when you resize your browser window. This is what I want to make).
http://www.templatemonster.com/demo/52266.html
I have posted my code to jsfiddle. Please find the link to my second comment below.
dimanche 21 août 2016
Copy character string to character pointer in C
Here is a simple program to demonstrate my problem.
I have a function functionB
which passes pointer to a character array to functionA
. functionA
finds the value and stores it to a character array. The content of character array should be copied to character pointer fdate
. How can I achieve this?
int functionB() {
char fdate[20];
functionA(&fdate[0]);
return 0;
}
int functionA(char *fdate) {
char date[20] = "20 May 2016";
strcpy(fdate, date);
return 0;
}
Is there a way to indicate audio download progress/buffer when using Howler.js?
I'm using Howler.js and trying to accomplish something like this:
However, Howler doesn't seem to have support for audio "progress" events. Anybody know how I could work around this?