• Breaking News

    Thursday, July 26, 2018

    Python Prevent lines from executing using sys, dis, and inspect Ask Programming

    Python Prevent lines from executing using sys, dis, and inspect Ask Programming


    Python Prevent lines from executing using sys, dis, and inspect

    Posted: 26 Jul 2018 12:21 PM PDT

    This is a challenge problem. I am only given three imports and cannot use more. I need to prevent one of three print statements from executing, and prevent a sys.exit line from executing as well.

    I don't really know where to start on this although I know it will involve disassembling the structure of the function and attempting to re write the bytecode so it doesn't execute, if that's even possible.

    Any and all help is so much appreciated.

    submitted by /u/Astronomical_Panda
    [link] [comments]

    Programming Challenge

    Posted: 26 Jul 2018 08:45 PM PDT

    So i'm trying to do some challenges on Hackerrank and it's fucking hard. Like really hard. I know Java and Python but whenever I look at the problem set they give you for both I just draw blanks. It also dosen't help that i've never really done challenges before. WHen I was in college and it was shown to us I just breezed right through them (teacher didn't check for it). Now that I know these things are used a lot in coding interviews and whiteboarding I actually want to learn how to do them.

    Anyone have any advice on how to start with this stuff?

    submitted by /u/3man75
    [link] [comments]

    Trying to load multiple c3 charts with React, sometimes showing

    Posted: 26 Jul 2018 03:33 PM PDT

    I am trying to map over an array in React and attach a C3 chart to each element. My best guess as to why it isn't showing up is that it is trying to render the charts before the divs are created but not sure as to why it is happening. I know you need multiple bind points if you want more than one chart so I am trying that. If anyone can help that would be great.

    graph(index) { c3.generate({ bindto: '#class' + index, data: { columns: [ [1, 2, 3], [2, 3,4] ], type: 'bar' }, bar: { width: { ratio: 0.3 // this makes bar width 50% of length between ticks } // or //width: 100 // this makes bar width 100px } })} render () { return ( <div> {this.props.foodResults.map((food, i) => { return ( <div key={i}> <div id={`class${i}`}>{this.graph(i)}</div> </div> ) })} </div> ) } 
    submitted by /u/hellpark
    [link] [comments]

    What is the most efficient way to create and append large amounts of HTML using PHP/JavaScript?

    Posted: 26 Jul 2018 03:28 PM PDT

    I'm working on a simple LAMP stack. There aren't many (if any) fancy technologies involved. PHP, HTML, JavaScript and jQuery mostly.

    What I'm currently working on is a page that will load with an empty list, and then dynamically create the elements to fill the list. While I can easily create those elements just fine through PHP on the initial load, I believe that the page will feel faster and smoother if the content is generated after the initial page load. What I'm unsure about is what the most effective and efficient way to create these list elements is.

    I am fetching data through an AJAX call, which is returned in JSON format. That data should then be inserted into the HTML list item. A list item is about ~35 lines of HTML when properly formatted.

    So the two options I see are: the HTML elements are generated with PHP, or they are generated through JavaScript.

    If I choose JavaScript, there are many ways I can do it:

    • HTML <template> tag
    • String concatenation (ie: '<div class="className"><h3>' + titleText + '</h3>...')
    • Document Fragments
    • document.createElement

    Through PHP I see less options:

    • send an AJAX call to a PHP script which gets the JSON data, creates the HTML, and returns the block of HTML entirely which is then inserted with javascript

    Honestly, any of these methods should probably work just fine. I'm not working with huge amounts of data here... at least not yet. But I'd still love to know what the best way to do this would be, if there is one.

    submitted by /u/coolRedditUser
    [link] [comments]

    Trying to make a datagrid with buttons for each row in winforms

    Posted: 26 Jul 2018 05:24 PM PDT

    Hey!

    I want to display all my products for my products table in a c# table.. I want a column for each of my table columns in my database (price, name, manufactured, etc). I also want each of my rows to have a button for deleting or updating that row. The number of rows is subject to change due to the fact that searching is allowed, and also due to the fact that rows can be added and deleted.

    I have the back end of this working perfectly. Im just struggling with the front end..

    any idea of how to do this in c# winforms?

    submitted by /u/Pothead20
    [link] [comments]

    How different is Java from C#?

    Posted: 26 Jul 2018 04:37 PM PDT

    Benefits of templating engine over GET from server?

    Posted: 26 Jul 2018 03:12 PM PDT

    I'm creating a "logged in" page that fetches user data with a GET request to the server after the initial page is loaded. I was wondering if I should use a templating engine like ejs that will include the data on page load and what benefits it would give me (ie, faster load times, etc).

    submitted by /u/Stormy1997
    [link] [comments]

    Invoke Python script on Raspberry Pi from a remote Windows PC using Java

    Posted: 26 Jul 2018 11:21 AM PDT

    The title says it all! I need to invoke a python script on a Raspberry Pi remotely from a PC using Java. I'm sure there are many ways to do this, and I just need some guidance on the easiest way(s). Thanks!

    submitted by /u/R0T0
    [link] [comments]

    I feel dumb for having to ask this question, but would including my github, which has potential ties to piracy, to my resume be a huge no-no?

    Posted: 26 Jul 2018 12:27 AM PDT

    as an example, one of my files makes a reference to thepiratebay but does not make any indication in favor of its use, but it's part of word list for filtering subtitles. Thoughts?

    submitted by /u/Sunny_Cakes
    [link] [comments]

    What is the most lightweight (least RAM) web server language, except PHP?

    Posted: 26 Jul 2018 04:37 AM PDT

    I'm working on a piece of software as a front-line defense in a web server environment. Extremely simple one. I'm a PHP developer myself.

    The front-line has one and only purpose: Layer-7 DDoS protection. Cloudflare or other third-party filters are not an option due to client requirements.

    The front-end will do this, and this alone:

    • When a HTTP(S) request comes in, check whether ddos_protection_active flag is set to "no", "globally" or "certain IPs only".
    • Check if the incoming client IP is in the blacklist for ddos protection. Check if the client IP is in whitelist (googlebot IPs etc).
    • If ddos protection is required, check whether a certain cookie exists and if the value matches a certain proof-of-work criteria.
    • If the cookie doesn't exist, print out an HTML page (which will include some javascript for further processing)

    After the HTML page is printed out, Javascript will do it's magic (display a captcha, or calculate a proof-of-work) and submit it to the web server.

    • The web server receives the JS-submitted value, check if the proof-of-work matches the internal value or verifies the captcha response. If it is valid, it sets a cookie and refreshes the page. Upon refresh, since a valid cookie exists now, HTML for ddos protection is skipped and the request is routed to the appropriate web server (which handles the complex page-serving tasks using PHP)

    I know how to do all of the above using PHP. It's an afternoon project for me. But since this is for DDoS protection, and the server-side language only needs to handle cookie checking and basic proof-of-work calculations along with some static HTML output, PHP is overkill. I need this to use as little RAM/CPU as possible, so it can handle a large amount of requests in a short time. Ideally, something that doesn't spawn a new process like PHP for every request, but instead a single request handles all incoming connections and passes along the validated connections to PHP.

    I use nginx for its efficiency for the PHP web server, but for this front-line I'm willing to learn. The PHP-side of the project will be handled by separate servers, so this front-line is going to have its own server that routes valid requests to other servers. There will be multiple front-line servers spread around using anycast networks.

    What are my best chances?

    submitted by /u/trippler1
    [link] [comments]

    How do I build JVM language?

    Posted: 26 Jul 2018 01:01 PM PDT

    I am looking for any simple tutorials about generating java byte code for a jvm language.

    submitted by /u/trixR4kidsWabit
    [link] [comments]

    JAX-RS CDI Problems.

    Posted: 26 Jul 2018 12:30 PM PDT

    I'm following this example to get the user object from a JWT https://github.com/Posya/wiki/blob/master/best-practice-for-rest-token-based-authentication-with-jax-rs-and-jersey.adoc#using-cdi-context-and-dependency-injection

    I'm running on jersey 2.26 on glassfish 4.1.1 and everything works fine in terms of setting the AuthenticatedUser object.

    The problem is arising when I'm trying to use that object in one of my routes.

    My Classes are all the same as in the example with some additional below.

    Here's my user class.

    public class User { private String username; User() { this.username = "asdf"; } public String getUsername() { return username; } } 

    And here's how I'm trying to use it one of my routes

    public class BaseURL { @Inject @AuthenticatedUser User authenticatedUser; BaseURL() { System.out.println(authenticatedUser.getUsername()); } } 

    I'm trying to access the AuthenticatedUser Object inside of this Class and I keep getting a NullPointerException. And here's a partial stacktrace of the error I'm getting

    MultiException stack 1 of 1 java.lang.NullPointerException at com.cphr.api.BaseURL.<init>(BaseURL.java:35) at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:119) 

    I've found a few answers on stackoverflow but none seem to really help. The main jist is that I either need a factory and need to bind classes and put it in ResourceConfig Class, but I don't understand any of that.

    Do I need to add a new dependency? Is there something missing in my web.xml? I'm completely stumped.

    I'm about to just give up and do things the way that make sense to me. Just put it in the BaseURL constructor and pass it to the other resources via their constructors. It's not the "jax-rs way" but it works completely fine for my use case.

    submitted by /u/ThatShitAintPat
    [link] [comments]

    How can I see the full orderer logs in Hyperledger Fabric basic-network sample?

    Posted: 26 Jul 2018 12:07 PM PDT

    I'm currently working on a project where I need to simulate the high throughput chaincode on a Hyperledger Fabric 1.1.0 blockchain application/infrastructure for load testing, but first I need to ensure that the first-network sample is working properly. I have all the correct binaries, as well as a clean download of the fabric-samples directory. When I run ./byfn.sh up the automated End-to-End test runs perfectly without a hitch, but my main concern is what's going on behind the scenes. So I open the logs for the orderer, however, it isn't giving me any useful info outside of some ambiguous warnings:

    $ docker logs -f orderer.example.com

    < config values >

    2018-07-26 18:34:42.025 UTC [orderer/common/server] Start -> INFO 006 Beginning to serve requests

    2018-07-26 18:34:44.594 UTC [msp] DeserializeIdentity -> INFO 007 Obtaining identity

    2018-07-26 18:34:44.595 UTC [msp] DeserializeIdentity -> INFO 008 Obtaining identity

    2018-07-26 18:34:44.600 UTC [msp] DeserializeIdentity -> INFO 009 Obtaining identity

    2018-07-26 18:34:44.607 UTC [fsblkstorage] newBlockfileMgr -> INFO 00a Getting block information from block storage

    2018-07-26 18:34:44.615 UTC [orderer/commmon/multichannel] newChain -> INFO 00b Created and starting new chain mychannel

    2018-07-26 18:34:44.830 UTC [msp] DeserializeIdentity -> INFO 00c Obtaining identity

    2018-07-26 18:34:50.989 UTC [msp] DeserializeIdentity -> INFO 00d Obtaining identity

    2018-07-26 18:34:57.281 UTC [msp] DeserializeIdentity -> INFO 00e Obtaining identity

    2018-07-26 18:34:57.526 UTC [msp] DeserializeIdentity -> INFO 00f Obtaining identity

    2018-07-26 18:34:57.535 UTC [common/deliver] Handle -> WARN 010 Error reading from 172.18.0.7:33608: rpc error: code = Canceled desc = context canceled

    2018-07-26 18:34:57.557 UTC [msp] DeserializeIdentity -> INFO 011 Obtaining identity

    2018-07-26 18:34:57.558 UTC [msp] DeserializeIdentity -> INFO 012 Obtaining identity

    2018-07-26 18:35:00.661 UTC [msp] DeserializeIdentity -> INFO 013 Obtaining identity

    2018-07-26 18:35:00.673 UTC [msp] DeserializeIdentity -> INFO 014 Obtaining identity

    2018-07-26 18:35:00.682 UTC [common/deliver] Handle -> WARN 015 Error reading from 172.18.0.7:33624: rpc error: code = Canceled desc = context canceled

    2018-07-26 18:35:00.687 UTC [msp] DeserializeIdentity -> INFO 016 Obtaining identity

    2018-07-26 18:35:00.688 UTC [msp] DeserializeIdentity -> INFO 017 Obtaining identity

    2018-07-26 18:35:20.665 UTC [msp] DeserializeIdentity -> INFO 018 Obtaining identity

    2018-07-26 18:35:43.483 UTC [msp] DeserializeIdentity -> INFO 019 Obtaining identity

    Normally, I'd be expecting information such as the orderer receiving transactions from the peer, at which point it groups them together into blocks and sends them back to the peer, but it doesn't seem to be doing anything useful. (Side note: eventually I plan on disabling TLS network-wide, however for now I don't want to mess with the network while trying to get the orderer logs)

    So my gut reaction is that something is going wrong in the peer, so I spin up the logs for that, and everything appears to be fine, however I get a couple of warnings:

    $ docker logs -f peer0.org1.example.com

    < ... >

    2018-07-26 17:56:08.518 UTC [gossip/comm] func1 -> WARN 026 peer1.org1.example.com:7051, PKIid:[96 141 193 216 138 109 43 60 154 212 136 174 210 228 71 15 212 18 103 171 228 71 30 210 169 234 137 229 237 185 160 17] isn't responsive: rpc error: code = Canceled desc = context canceled

    2018-07-26 17:56:08.518 UTC [gossip/discovery] expireDeadMembers -> WARN 027 Entering [[96 141 193 216 138 109 43 60 154 212 136 174 210 228 71 15 212 18 103 171 228 71 30 210 169 234 137 229 237 185 160 17]]

    2018-07-26 17:56:08.518 UTC [gossip/discovery] expireDeadMembers -> WARN 028 Closing connection to Endpoint: peer1.org1.example.com:7051, InternalEndpoint: peer1.org1.example.com:7051, PKI-ID: [96 141 193 216 138 109 43 60 154 212 136 174 210 228 71 15 212 18 103 171 228 71 30 210 169 234 137 229 237 185 160 17], Metadata: []

    2018-07-26 17:56:08.520 UTC [gossip/discovery] expireDeadMembers -> WARN 029 Exiting

    < ... >

    2018-07-26 17:56:21.263 UTC [gossip/service] updateEndpoints -> WARN 036 Failed to update ordering service endpoints, due to Channel with mychannel id was not found

    2018-07-26 17:56:21.348 UTC [kvledger] CommitWithPvtData -> INFO 037 Channel [mychannel]: Committed block [1] with 1 transaction(s)

    2018-07-26 17:56:24.353 UTC [gossip/service] updateEndpoints -> WARN 038 Failed to update ordering service endpoints, due to Channel with mychannel id was not found

    < ... >

    Upon making transactions on this network with the docker cli, i am able to invoke/query just fine with the expected functionality, but I still get nothing from the orderer logs.

    I'm particularly wondering about that second group of warnings on the peer- could it be there's some communication error with the orderer? I can verify that I'm using the channel name mychannel system-wide so I don't see why it'd be giving me any issues.

    I've been at this for two full days now and I'm at my wit's end. Is there some logging level value that I'm missing somewhere within the Orderer chaincode? Would love some insight into the how I can generate output on the Orderer node. thanks!

    submitted by /u/yanksin1st
    [link] [comments]

    Server PHP script for software validation

    Posted: 26 Jul 2018 08:12 AM PDT

    I have built a C# app and would like to implement my own simple and tidy license validation.

    The app will make an HTTPS request against my server, in the request I will include the user's email address they used at purchase time and their key that is distributed at purchase time.

    My php script will take the email and key and hash those with my own protected logic and check against a mysql table of hashed values. if the hashed value exists in the table, all good, and my C# app will handle the http request accordingly.

    I am unsure, though, of the accessibility of the php script, as it needs to be secret as it will contain the hashing logic. The php file will also need my credentials to access the mysql table, so lump that concern in as well. Can I put those credentials in as well and not have to worry.

    Am I being overly concerned about the php source files being accessible to malicious downloaders? Do I need to take any steps to insure the script file is not accessible to third parties?

    submitted by /u/ArchieTect
    [link] [comments]

    How to add the total number of random numbers stored in a variable?

    Posted: 26 Jul 2018 09:34 AM PDT

    Hello! I'm currently making a practice program in IDL right now. I'm trying to generate a random number of photons in a random number generator with a poisson distribution of 500. Basically what my program is doing is generating opaque regions and gap regions in this one space and then randomly distributing photons through a gap. However, I don't have much experience programming so I'm kind of stuck on how to go about this one concept. I have my randomly generated photons that are printed in the segment of the code that says ";;Generate a random value for photon number." Then I print that value. However, what I wanted to do was print the total of all of these values that are generated. Sometimes it might be 3 values or 4. For example for one photonCycle 520, 480, 501 photons might be generated or 500, 492, 510, 495. If anyone could help me out I would appreciate it!

    Here is a picture of my code: https://imgur.com/a/m2ENd4D

    submitted by /u/finn_2
    [link] [comments]

    Avatrar maker

    Posted: 26 Jul 2018 06:19 AM PDT

    Hello guys :)
    I am searching for an avatar maker which i can implement into my app i am planning to develop.
    It'll be developed in flutter so i think i have to make the most parts by myself, but i am not a good designer so i need your help guys

    thank you!!

    submitted by /u/kiesman99
    [link] [comments]

    No comments:

    Post a Comment