on-internet

Good Values for Knuth's multiplication method - Hashing

Any guesses what are good values for the "c"? // h(k) = ⌊(m · (k · c − ⌊k · c⌋)⌋ return (int) Math.floor(distinctElements * (key * c - Math.floor(key * c))); I have found the this one: (Math.sqrt(5)-1)/2) However are there any other good choices known? Kind regards

Join the discussion →

Play local .avi videos in Node.js / Electron app

Maddening gap in an app I'm developing is there appears to be little (or no) support for AVI in the HTML5 video implementation. So, I need a workaround that is cross-platform, and package-able with my electron app. Videos are hosted locally I'm not averse to encoding on the fly (ffmpeg avi -> mp4 and use HTML5 natively?) WebChimera appears dying due to VLC and Electron changes (devs can't keep up) (Is there another npm package that can do this?) A wrapper that calls a native VLC instance might work -- but how do I ensure that VLC is available on the system with my packaging? Should I just spaw

Join the discussion →

php - is it possible to define properties for methods?

I would like to define some properties in a method that are contained within that method i.e not the the entire class. But want to do this from the instance of the object. Is that possible? The code below does not work. class foo{ var $x; function __construct(){ } function abc(){ echo $y; } } $new = new foo(); $new->abc->y = "bar";

Join the discussion →

Playing AUDIO from WebView

I've been looking for how to play audio from any website inside the webview? I've noticed Chrome Browser playing the audio but My WebView app doesn't play. Can you please provide me any resource or code snippet? Thanks in Advance!

Join the discussion →

How to serialize subtypes with MsgPack in C#

i have a question regarding msgpack serialization in c#. I have a base class and a class derived from base, each of them holding properties, for example: class Base { int PropertyA { get; set; } } class DerivedFromBase : Base { int PropertyB { get; set; } } Additionally i have an object of a third class Container, for example: class Container { Base ContainerProperty { get; set; } } My problem is, if ContainerProperty is of type DerivedFromBase, MsgPack serializes only PropertyA, not PropertyB! How can i achieve, that MsgPack internally recognize ContainerProperty to be a DerivedFromBase? Do i

Join the discussion →

Get list of physical interfaces in openwrt

How we can get all physical interfaces in openwrt, I tried with ls -l /sys/class/net/, But it is not right information. lrwxrwxrwx 1 root root 0 Mar 21 10:26 eth0 -> ../../devices/virtual/net/eth0 lrwxrwxrwx 1 root root 0 Mar 21 10:26 eth1 -> ../../devices/virtual/net/eth1 lrwxrwxrwx 1 root root 0 Mar 21 10:26 tun0 -> ../../devices/virtual/net/tun0 lrwxrwxrwx 1 root root 0 Mar 22 09:50 wlan0 -> ../../devices/pci0000:01/0000:01:00.0/net/wlan0 lrwxrwxrwx 1 root root 0 Mar 22 09:50 wlan0-1 -> ../../devices/pci0000:01/0000:01:00.0/net/wlan0-1 actually eth0 and eth1 are physical and wlan0-1 is logi

Join the discussion →

Disable file upload using htaccess

Recently, one of my clients website has been attacked. I noticed there, in the tmp directory attacker uploaded php script, where a user can upload images. My question is, is it possible to stop uploading any files other than images using HTACCESS? The website is built on Codeigniter. Thanks in advance. Any type of help is appreciated.

Join the discussion →

Save entity object with foreign key using CrudRepository

I have two entity classes with @ManyToOne relationship as below. @Entity public class Student { @Id private Integer studentId; @Column(nullable = false) private String studentName; @ManyToOne(targetEntity = School.class, fetch = FetchType.LAZY, optional = false) @JoinColumn(referencedColumnName = "schoolId", insertable = false, updatable = false) private School school; //Getters and Setters methods . @Entity public class School { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer schoolId; @Column(nullable = false) private String schoolName; //Getters and Setters methods When

Join the discussion →

mkimage doesn't add public key to .dtb file

I am trying to make a verified boot on beaglebone black by following the documentation https://github.com/01org/edison-u-boot/blob/master/doc/uImage.FIT/beaglebone_vboot.txt when i run the command to put public key into .dtb file mkimage -f sign.its -K am335x-boneblack.dtb -k keys -r image.fit I get the output FIT description: Beaglebone black Created: Fri Mar 24 18:47:51 2017 Image 0 (kernel@1) Description: unavailable Created: Fri Mar 24 18:47:51 2017 Type: Kernel Image Compression: lzo compressed Data Size: 8490316 Bytes = 8291.32 KiB = 8.10 MiB Architecture: ARM OS: Linux Load Address: 0x8

Join the discussion →

Regular expression for email masking

I am trying to write a regular expression to mask an email address. Example below. input: [email protected] output: j*******@e*********.com I have tried the following but I just can't seem to get it working correctly. regex:(?<=.).(?=[^@]\*?@) output:j*******@example.en.com regex:(?<=.).(?=[^@]\*?)(?=[^\.]\*?\.) output:j******************.com Any help would be appreciated. demo

Join the discussion →

Can't canonicalize query: BadValue $or/$and/$nor entries need to be full objects - Doctrine

I am trying to covert this query db.getCollection('queues').find({ $and:[ {queue: 'testo'}, {$or: [ {$and: [{reserved_at: null}, {available_at:{'$lte':1490323024}}]}, {reserved_at:{'$lte':1490323024}} ]} ] }); to doctrine but I am getting this error. Can't canonicalize query: BadValue $or/$and/$nor entries need to be full objects. This is what I tried. $builder = $this->get('doctrine_mongodb')->getManager()->createQueryBuilder('AppBundle:Ticket'); $builder->findAndUpdate()->addAnd([ $builder->field('queue')->equals($queue), $builder->addOr([ $builder->addAnd([ $builder->field('reservedAt')->eq

Join the discussion →

Running Spark-Shell on Windows

I have downloaded spark, sbt, scala, and git onto my Windows computer. When I try and run spark-shell in my command prompt, I get "Failed to find Spark assembly JAR. You need to build Spark with sbt\sbt assembly before running this program." I tried to follow this guide: https://x86x64.wordpress.com/2015/04/29/installing-spark-on-windows/ ,but I don't have a build subfolder so I am not sure if that is the problem. Any help would be appreciated.

Join the discussion →

How do you delete a remote annotated tag? [duplicate]

Suppose I have committed an annotated tag and pushed it. Can I delete it from the remote (& if so how)? What are the safety implications of deleting it - i.e. in what situations will it break stuff? Is any of that changed if I have already committed other normal commits after it (are annotated commits leaf nodes or do they have children?). From git docs: Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recomme

Join the discussion →

Trilateration different approaches and issues

Although there exists several posts about (multi)lateration, i would like to summarize some approaches and present some issues/questions to better clarify the approach. It seems that are two ways to detect the target location; using geometric/analytic approach (solving directly the equations with some trick) and fitting approach converting from non-linear to linear system. With respect to the first one i would like to ask few questions. Suppose in the presence of perfect range measurements,considering 2D case, the exact solution is a unique point at three circles intersection. Can anyone point

Join the discussion →

How to set headers in Soap Request Java

I am facing issue in forming a SOAP request. In that request i am supposed to add username , password and some other info in header part not the part of payload. Below the Entry in wsdl <wsdl:message name="InputUploadCustomerDocument_Headers"> <wsdl:part name="DocumentType" element="tns:DocumentType"/> <wsdl:part name="FileName" element="tns:FileName"/> <wsdl:part name="Password" element="tns:Password"/> <wsdl:part name="PinNo" element="tns:PinNo"/> <wsdl:part name="UserName" element="tns:UserName"/> </wsdl:message> <wsdl:message name="ReturnUploadCustomerDocument"> <wsdl:part name="parameters

Join the discussion →

Why do I get "Call to a member function on null ..." on a variable that my class initializes in its constructor? [closed]

I have done all sorts of things to understand what is actually wrong with the code, but I just couldn't figure out what was causing this error. Below is class called Topic: class Topic { // Init DB variables private $db; /* * Constructor */ public function __contruct() { $this->db = new Database(); } /* * Get All Topics */ public function getAllTopics() { $this->db->query("SELECT topics.*, users.username, users.avatar, categories.name FROM topics INNER JOIN users ON topics.user_id = users.id INNER JOIN categories ON topics.category_id = categories.id ORDER BY create_date DESC"); // Assign the

Join the discussion →

Why do I get "Call to a member function on null ..." when declaring a new __construct function? [closed]

I have done all sorts of things to understand what is actually wrong with the code, but I just couldn't figure out what was causing this error. Below is class called Topic: class Topic { // Init DB variables private $db; /* * Constructor */ public function __contruct() { $this->db = new Database(); } /* * Get All Topics */ public function getAllTopics() { $this->db->query("SELECT topics.*, users.username, users.avatar, categories.name FROM topics INNER JOIN users ON topics.user_id = users.id INNER JOIN categories ON topics.category_id = categories.id ORDER BY create_date DESC"); // Assign the

Join the discussion →

Android implement Parcelable objects with hashmap that contains another hashmap

This is an extension for Android implement Parcelable object which has hashmap but mine is a little different. I have these classes public class EventDetails implements Parcelable { Private String id; Private String eventName; Private Long eventUnixTime; Private HashMap <String, User> pickedUser = null; } and public class User implements Parcelable { private String email; private String userName; private String userPicture; private Boolean hasLoggedInWithPassword; private HashMap<String, Object> dateJoined = null; public User() { } public User(String email, String userName, String userPicture,

Join the discussion →

java.sql.SQLException: Listener refused the connection with the following error: ORA-12505

Hi i am beginner and present I have installed Oracle 10g Express Edition Release 2 in my windows 7 64 bit OS and tried to execute Hibernate program but i am getting below exceptions can some one help me please WARNING: Could not obtain connection metadata java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connection descriptor used by the client was: localhost:1521:xe at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseErro

Join the discussion →

String encoding issue in Spark SQL/DataFrame

So I have this csv file which has two columns: id (int), name(string). When I read the file into pyspark throught the following code: schema = StructType([ StructField("id", IntegerType(), True), StructField("name", StringType(), True)]) df = sqlContext.read.csv("file.csv", header=False, schema = schema) On executing df.first() I get the following output: Row(artistid=1240105, artistname=u'Andr\xe9 Visior') This is the original row from the file: 1240105,André Visior How do I go about displaying the name as it is?

Join the discussion →

Serialize and deserialize a collection to JSON Delphi

I've searched a lot, but cannot find a working solution. Most likely because I'm pretty new to Delphi (and coming from C#). I have a unit with the following class declaration: TReplaceField = class public Key: string; Value: string; constructor Create; overload; constructor Create(strKey, strValue: string); overload; end; Class can also be record, like suggested in the comment. I want to create a collection of it, be it an array, TList<T>, or whatever suits best in this case, and then serialize it to JSON (to store it) and later deserialze it to loop over the fields. I've found REST.JSON and T

Join the discussion →

org.springframework.orm.jpa.JpaSystemException: null id generated for:class oneToOne

As the title,I got the following exception when I try to save Datas using Spring Data jpa.Please help me out to solve this problem because I still couldn't solve though searching familiar problems. Class Activity: @Entity @Table(name = "activity") @Access(AccessType.FIELD) public class Activity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String activityName; private String startTime; private String endTime; @OneToOne(fetch = FetchType.LAZY, mappedBy = "activity", cascade = CascadeType.ALL, optional = false) private ActivityContent

Join the discussion →

Handling External Links in android WebView like Gmail App does

I'm a web developer. I'm currently developing android application on Android Studio using WebView which access my website as an android application. One of my webpage contains many external links. My goal is to make the android application can handle external links like Gmail App does (also like facebook and Line do). Below is the example of gmail app. An email contains external link Link clicked, then application open a new activity acts like a browser without leaving Gmail application Any idea how to make it?

Join the discussion →

Why is my imported module grayed out in PyCharm but still needed to run?

I am very new to programming and I don't understand why the module I imported from mpl_toolkits.mplot3d import Axes3D is grayed out in PyCharm. If I run the program without it, I get errors. I'm sure there are plenty of things wrong with what I'm doing in this program. I'm just trying to get a contour graph of a specific function and a surface plot. Any suggestions would be much appreciated. from mpl_toolkits.mplot3d import Axes3D # <-- Gray import numpy as np from numpy import arange from pylab import meshgrid, imshow, contour, colorbar, show from matplotlib import cm from matplotlib.ticker i

Join the discussion →

Getting InvalidArgumentError in Tensorflow

I created a CNN for predicting the labels of an image. I trained it. Now i want to use my model for predicting the labels for new image. My code for CNN is this:- def LeNet(x): # Arguments used for tf.truncated_normal, randomly defines variables for the weights and biases for each layer mu = 0 sigma = 0.1 # SOLUTION: Layer 1: Convolutional. Input = 32x32x3. Output = 28x28x6. conv1_W = tf.Variable(tf.truncated_normal(shape=(5, 5, 3, 6), mean = mu, stddev = sigma)) conv1_b = tf.Variable(tf.zeros(6)) conv1 = tf.nn.conv2d(x, conv1_W, strides=[1, 1, 1, 1], padding='VALID') + conv1_b # SOLUTION: Act

Join the discussion →

About tarjan algorithm, why can't we take low[v] instead of disc[v] when considering the backward edge?

I read an article about Tarjan's algorithm, blog. In this article, the author asks a question: In case two, can we take low[v] instead of disc[v] ?? . Answer is NO. If you can think why answer is NO, you probably understood the Low and Disc concept. I don't know why. When I am reading the similar article in wiki, I found that the code can be like that: else if (w.onStack) then // Successor w is in stack S and hence in the current SCC v.lowlink := min(v.lowlink, w.lowlink) I wanna know why the author say the answer is NO. Thanks for answering my question. Have a good day.

Join the discussion →

Storing content along with special characters in PHP [duplicate]

I have an add_post form which include post_title, post_content and date. post_content may contain special_characters and HTML elements There is a problem to store into post_content Example string: gyms revolve around this unique factor called “Community.” If I try to insert that string into the database table the following string is inserted for instance: gyms revolve around this unique factor called Because of the symbols (“ ” ’) I am not able to insert the all data I just want to remove these symbols so that I would be able to add all post_content data This is what I have tried: $post_conten

Join the discussion →

Javascript Prompt Box Loops

Something is wrong with this code but I can't figure out what it is. The page does not work properly or do what it's supposed to. I need a code that prompts for a password and that limits the attempts to 3. After the third attempt, it needs to have an alert box. <script> var attempts = 3; var answer = prompt("Password: "); while (attempts != 0) { if (answer == "Psycho") { document.write("These are pictures of my kitten and her things."); } else { answer = prompt("Password: "); attempts--; } } if (attempts = 0) { alert("Incorrect Password"); } </script>

Join the discussion →

How to access the instantiated object after loading a custom library in CodeIgniter

An Error Was Encountered Unable to load the requested class: Plugin_update_checker I am using custom library which create a dynamic php file with 740 line code controller function: public function create() { // ... irrelevant, working code ... // Can't Load this Library ------------------- $this->load->library('Plugin_update_checker'); // ------------------------------------------- $php_code = new plugin_update_checker(); $dir = 'api/' . $repo->sum($userId, 1548) . '-' . $repo->slug($userName) . '/plugins/'; $file_name = 'WinnRepo' . $repo->slug_space($data['title']) . 'PluginUpdater_'.$key; $

Join the discussion →

Group-Object is showing a hashtable when using calculated properties

Background From list of predefined servernames, I'm searching in config files and trying to group for each server all the files where it's found. A filename can be mapped to an application. Problem The grouping part is giving me problems. It keeps returning a hashlist where I just want the filename returned. SSCCE note: grouping is on filename in the sscce but the gist of the problem is the same This example is showing the entire line where the match is found instead of just the match @("A test", "Another test") | sls -pattern "\btest\b" | group filename | select name, group Trying to adjust f

Join the discussion →
Older stories