samedi 9 janvier 2016

How to draw a Huffman tree properly

Vote count: 0

I have the following symbols and probabilities and I would like to draw a Huffman tree for them:

s = 0.04 || i = 0.1 || n = 0.2 || b = 0.04 || a = 0.3 || d = 0.26 || ~ = 0.06

Based on Huffman algorithm, I generated the following tree:

enter image description here

This was done by:

  1. Join s + i
  2. Join the result of 1 and n
  3. Join ~ + d
  4. Join b + a
  5. Join the result of 3 and 4
  6. Join the result of 5 and 2

My questions: is what I have done right or not? If so, is it acceptable that the final probability (result of 6) greater than 1?

Thanks

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How to draw a Huffman tree properly

php, sql INSERT TO not working when ACTION links to another page

Vote count: 0

My player message system isn't working. You start on the Diplomacy page which lists the player nations. Once a player nation is selected they are sent to the send message page which shows any messages between themselves and the nation selected. It also gives them a message box to write their own message to send. Here is the code.

if(isset($_POST['message']) && !empty($_POST['message'])){
    $sender = $_GET['nation'];
    $receiver = $_GET['receiver'];
    $random_number = rand();
    $message = $_POST['message'];
    $type = $_GET['type'];

    $check_con = mysql_query("SELECT `hash` FROM `message_group` WHERE (`user_one`='$sender' AND `user_two`='$receiver') OR (`user_one`='$receiver' AND `user_two`='$sender')");

    if(mysql_num_rows($check_con) ===1){
        $get_hash = mysql_fetch_assoc($check_con);

        $hash = $get_hash['hash'];
        mysql_query("INSERT INTO messages (group_hash, from_id, message, seen) VALUES('$hash','$sender','$message','0')");
        echo "<p>Message Sent!</p>";
   }else{   
        mysql_query("INSERT INTO message_group (user_one, user_two, hash) VALUES('$sender','$receiver','$random_number')");
        mysql_query("INSERT INTO messages (group_hash, from_id, message, seen) VALUES('$random_number','$sender','$message','0')");
        echo "<p>Conversation Started!</p>"; 
    }
    }
    ?>
    <form method="POST" action="index.php?page=gc3025/send_beta.php&game=<?php echo $game; ?>&type=<?php echo $type; ?>&nation=<?php echo $nations_id; ?>&user=<?php echo $user_id; ?>&receiver=<?php echo $receiver_id; ?>">
    <table>
    Enter Message:
    <tr>
   <td></td>
   <td><textarea name='message' rows='7' cols='60'></textarea></td>
   </tr>
    <td><input type='submit' value="Send Message" /></td>
    </table>
    </form>

If under FORM ACTION I link the page to itself it works but you have to refresh the page to see the new message which also resends the message. If the FORM ACTION goes to the previous page then it does not INSERT the message into the table on the server.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



php, sql INSERT TO not working when ACTION links to another page

Python Using A Microphone

Vote count: 0

I was watching Avengers and I thought it would be it wresting to make something like Jarvis with Python which is what I'm doing. I've only been doing Python for 1 year ( I'm 15) so I'm not the best.

So basically, I want to make something basic at the beginning where if I say "Cameron, activate" it will out put to the speakers "Cameron activated". Them if I say "hello" it'll reply "hello".

I first want to know if this is possible and if so, could someone help me with it?? Thanks so much!

asked 29 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Python Using A Microphone

jQuery validation error "not defined"

Vote count: 0

When validating the jQuery I receive the followers 2 errors: "'$' was used before it was defined." & "'window' was used before it was defined." What does this mean? & how do I remove these errors? Thank you :-)

var lastScrollTop = 0;
$(window).scrollTop(0);

$(window).on('scroll', function() {
    var header = $('header');
    var content = $('content');
    var headerBg = $('.header-bg');
    var headerCnt = $('.header-content');
    var scrollTop = $(window).scrollTop();
    var dynHeaderVisible = false;
  
    if (lastScrollTop > scrollTop) {
      if (scrollTop <= 400) {
        headerBg.css("height", 0);
        headerCnt.css('color', 'white');
      } else {
        headerBg.css("height", 80);
        headerCnt.css("height", 80);
        headerCnt.css('color', 'black');
      }
    } else {
      // Down
      if (scrollTop > 350) {
        console.log ("hi");
        headerCnt.css("height", 0);
        headerBg.css("height", 0);
      }
    }
    
    lastScrollTop = scrollTop;
});

$.fn.isOnScreen = function(){
    var element = this.get(0);
    var bounds = element.getBoundingClientRect();
    return bounds.top < window.innerHeight && bounds.bottom > 0;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  list-style: none;
  text-decoration: none;
  font-size:1em;
  font-family: Helvetica Neue, Helvetica, Arial, Sans-serif;
  }
        a {
    background:transparent;
    border:none;
    letter-spacing:0.15em;
    text-transform:uppercase;
    transition: .3s color;
        transition: .3s height;
        }


header {
  display: block;
  position: fixed;
  height: 80px;
  width: 100%;
}

header ul {
  z-index: 20;
}

.header-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: transparent;
}

.header-bg,
.header-content {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
}

.header-bg {
  z-index: 100;
  color: gray;
  background-color: white;
  border-bottom: 1px solid black;
  transition: .3s height;
  height: 0;
}

.header-content {
  z-index: 200;
  transition: .3s color;
  color: white;
  background-color: transparent;
  height: 80px;
  transition: .3s height;
  overflow: hidden;
  list-style: none;
}

.logo {
    position: absolute;
    left: 47%;
        color: inherit;
    display: inline-block;
    width: 15px;
    height: 15px;
    padding: 18px;
    cursor: pointer;
    font-size:.8em;
    letter-spacing:0.05em;
        transition: .3s color;
        }

content {
  display: block;
  height: 2000px;
  background-color: orange;
}

.stage {
    color: #fff;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    height: 100vh;
    background-color: white;
        border-bottom: 1px solid black;
    font-size: 48px;
        height: 200px;
        width: 100%;
}

.stage-0 {
    background: grey;
    height: 400px;
}
<script src=     "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<header>
  <div class="header-wrapper">
    <div class="header-bg"></div>
    <div class="header-content">
      <ul>
        <li>
        <a href="" class="logo">Logo </a>
        </li>
      </ul>
    </div>
  </div>
</header>
<content>
<div class="stage stage-0">1</div>
<div class="stage stage-2">3</div>
<div class="stage stage-4">5</div>
<div class="stage stage-6">7</div>
<div class="stage stage-8">9</div>
<div class="stage stage-10">11</div>
<div class="stage stage-12">13</div>
<div class="stage stage-14">15</div>
<div class="stage stage-16">17</div>
<div class="stage stage-18">19</div>
<div class="stage stage-20">21</div>
<div class="stage stage-22">23</div>
</content>
asked 30 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



jQuery validation error "not defined"

Choropleth example in D3 is not working properly

Vote count: 0

I have this straight forward example where I wanted to use my data and my topojson instead. I get the data loaded but the visualization is not working properly. Data is loaded properly

Logging the dataRange() gives my -INFINITY,INFINITY, so something with the ranging is noch wokring but I can't see what it is.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>d3 choropleth map</title>
    <style>
      #wrapper {
          width: 960px;
          margin: -30px auto 0;
      }
      #map {
          width: 960px;
          height: 580px;
          position: relative;
      }
      .stroke {
        fill: none;
        stroke: #888;
        stroke-width: 2px;
      }

      .fill {
        fill: #fff;
      }

      .graticule {
        fill: none;
        stroke: #777;
        stroke-width: .5px;
        stroke-opacity: .5;
      }

      .land {
        fill: #222;
      }

      .boundary {
        fill: none;
        stroke: #fff;
        stroke-width: .5px;
      }
      .country {
          fill: steelblue;
          stroke: white;
      }
      #play, #clock {
        position: absolute;
        top: 15px;
      }
      #play {
        left: 15px;
      }
      #clock {
        left: 65px;
      }
    </style>
</head>

<body>

    <div id="wrapper">
        <div id="map"></div>
      <button id="play">play</button>
      <span id="clock">year</span>
    </div>


<script src="http://ift.tt/JmLP3T"></script>
<script src="http://ift.tt/1oOECWY"></script>
<script src="http://ift.tt/1hUyqi2"></script>
<script src="http://ift.tt/JmLP3U"></script>
<script>
  //globals
var width, height, projection, path, graticule, svg, attributeArray = [], currentAttribute = 0, playing = false;




function init() {

  setMap();
  animateMap();

}

function setMap() {

  width = 960, height = 580;  // map width and height, matches

  var projection = d3.geo.mercator()
      .translate([width / 2, height])
      //.scale((width - 1) / 2 / Math.PI);
      .scale(400);

  path = d3.geo.path()  // create path generator function
      .projection(projection);  // add our define projection to it

  graticule = d3.geo.graticule(); // create a graticule

  svg = d3.select("#map").append("svg")   // append a svg to our html div to hold our map
      .attr("width", width)
      .attr("height", height);

  svg.append("defs").append("path")   // prepare some svg for outer container of svg elements
      .datum({type: "Sphere"})
      .attr("id", "sphere")
      .attr("d", path);

  svg.append("use")   // use that svg to style with css
      .attr("class", "stroke")
      .attr("xlink:href", "#sphere");

  svg.append("path")    // use path generator to draw a graticule
      .datum(graticule)
      .attr("class", "graticule")
      .attr("d", path);

  loadData();  // let's load our data next

}

function loadData() {

  queue()   // queue function loads all external data files asynchronously
    .defer(d3.json, "mapdata/germany.json")  // our geometries
    .defer(d3.csv, "choroplethmap.csv")  // and associated data in csv file
    .await(processData);   // once all files are loaded, call the processData function passing
                           // the loaded objects as arguments
}

function processData(error,world,countryData) {
  // function accepts any errors from the queue function as first argument, then
  // each data object in the order of chained defer() methods above

  var countries = world.objects.states_germany.geometries  // store the path in variable for ease
  //console.log(countries);
  for (var i in countries) {    // for each geometry object
    for (var j in countryData) {  // for each row in the CSV
      console.log(countryData[j]);
      if(countries[i].id == countryData[j].id) {
        //console.log("SUCCESS");   // if they match
        for(var k in countryData[i]) {   // for each column in the a row within the CSV
          if(k != 'name' && k != 'id') {  // let's not add the name or id as props since we already have them
            if(attributeArray.indexOf(k) == -1) {
               attributeArray.push(k);  // add new column headings to our array for later
            }
            countries[i][k] = Number(countryData[j][k])  // add each CSV column key/value to geometry object
          }
        }
        break;  // stop looking through the CSV since we made our match
      }
    }
  }
  d3.select('#clock').html(attributeArray[currentAttribute]);  // populate the clock initially with the current year
  drawMap(world);  // let's mug the map now with our newly populated data object
}

function drawMap(world) {

    svg.selectAll(".country")   // select country objects (which don't exist yet)
      .data(topojson.feature(world, world.objects.states_germany).features)  // bind data to these non-existent objects
      .enter().append("path") // prepare data to be appended to paths
      .attr("class", "country") // give them a class for styling and access later
      .attr("id", function(d) { return "code_" + d.properties.id; }, true)  // give each a unique id for access later
      .attr("d", path); // create them using the svg path generator defined above

    var dataRange = getDataRange(); // get the min/max values from the current year's range of data values
    d3.selectAll('.country')  // select all the countries
    .attr('fill-opacity', function(d) {
        return getColor(d[attributeArray[currentAttribute]], dataRange);  // give them an opacity value based on their current value
    });
}

function sequenceMap() {

    var dataRange = getDataRange(); // get the min/max values from the current year's range of data values
    d3.selectAll('.country').transition()  //select all the countries and prepare for a transition to new values
      .duration(750)  // give it a smooth time period for the transition
      .attr('fill-opacity', function(d) {
        return getColor(d[attributeArray[currentAttribute]], dataRange);  // the end color value
      })

}

function getColor(valueIn, valuesIn) {

  var color = d3.scale.linear() // create a linear scale
    .domain([valuesIn[0],valuesIn[1]])  // input uses min and max values
    .range([.3,1]);   // output for opacity between .3 and 1 %

  return color(valueIn);  // return that number to the caller
}

function getDataRange() {
  // function loops through all the data values from the current data attribute
  // and returns the min and max values

  var min = Infinity, max = -Infinity;
  d3.selectAll('.country')
    .each(function(d,i) {
      var currentValue = d.properties[attributeArray[currentAttribute]];
      if(currentValue <= min && currentValue != -99 && currentValue != 'undefined') {
        min = currentValue;
      }
      if(currentValue >= max && currentValue != -99 && currentValue != 'undefined') {
        max = currentValue;
      }
  });
  console.log([min,max]);
  return [min,max];  //boomsauce
}

function animateMap() {

  var timer;  // create timer object
  d3.select('#play')
    .on('click', function() {  // when user clicks the play button
      if(playing == false) {  // if the map is currently playing
        timer = setInterval(function(){   // set a JS interval
          if(currentAttribute < attributeArray.length-1) {
              currentAttribute +=1;  // increment the current attribute counter
          } else {
              currentAttribute = 0;  // or reset it to zero
          }
          sequenceMap();  // update the representation of the map
          d3.select('#clock').html(attributeArray[currentAttribute]);  // update the clock
        }, 2000);

        d3.select(this).html('stop');  // change the button label to stop
        playing = true;   // change the status of the animation
      } else {    // else if is currently playing
        clearInterval(timer);   // stop the animation by clearing the interval
        d3.select(this).html('play');   // change the button label to play
        playing = false;   // change the status again
      }
  });
}


window.onload = init();  // magic starts here



</script>
</body>
</html>

So where is the mistake? You can finde the full data (map etc) here

asked 44 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Choropleth example in D3 is not working properly

Convert javascript class instance to plain object preserving methods

Vote count: 0

I want to convert an instance class to plain object, without losing methods and/or inherited properties. So for example:

class Human {
    height: number;
    weight: number;
    constructor() {
        this.height = 180;
        this.weight = 180;
    }
    getWeight() { return this.weight; }
    // I want this function to convert the child instance
    // accordingly
    toJSON() {
        // ???
        return {};
    }
}
class Person extends Human {
    public name: string;
    constructor() {
        super();
        this.name = 'Doe';
    }
    public getName() {
        return this.name;
    }
}
class PersonWorker extends Person {
    constructor() {
        super();
    }
    public report() {
        console.log('I am Working');
    }
    public test() {
        console.log('something');
    }
}
let p = new PersonWorker;
let jsoned = p.toJSON();

jsoned should look like this:

{
    // from Human class
    height: 180,
    weight: 180,
    // when called should return this object's value of weight property
    getWeight: function() {return this.weight},

    // from Person class
    name: 'Doe'
    getName(): function() {return this.name},

    // and from PersonWorker class
    report: function() { console.log('I am Working'); },

    test: function() { console.log('something'); }
}

Is this possible to achieve, and if so, how?

In case you're wondering, I need this because I am using a framework that, unfortunately, accepts as input only a json object, whereas I am trying to use typescript and class inheritance.

asked 57 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Convert javascript class instance to plain object preserving methods

Android Studio cannot resolve symbol ITelephony

Vote count: 0

I'm working on an Android app that is supposed to block incoming calls and (eventually) messages. So far I've read that you can use the internal ITelephony interface to intercept and eventually block calls.

One step of that process involves creating a package called "com.android.internal.telephony" containing a "ITelephony.aidl" file. I've got the following path right now:

\MyApp\app\src\main\java\company\MyApp\com\android\internal\telephony\ITelephony.aidl (this is what Android Studio creates with the "Create Package" command.

The issue is that, for some reason, I get the following error:

error: package com.android.internal.telephony does not exist. I've tried placing the aidl file in different locations but with the same result. Am I doing something wrong and, if so, how do I solve this?

Thanks.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Android Studio cannot resolve symbol ITelephony

How to undo selected / highlighted text when click on button with codemirror

Vote count: 0

I have a simple codemirror text editor I am working on with bootstrap. I can click on my bold and code buttons OK and it wraps the selected / highlighted text corrctly.

Question: When text is wrapped in a tag lets say <b>something</b> If I go and select / highlight it again and click same bold button how can I undo it in codemirror?

Here's a CodePen example

Script

<script type="text/javascript">
$(document).ready(function() {
    var editor = document.getElementById('text-editor');

    $("#text-editor").each(function (i) {

        editor = CodeMirror.fromTextArea(this, {
            lineNumbers: true,
            mode: 'html',

        });

        editor.on("change", function() {
            document.getElementById('question-preview').innerHTML=editor.getValue();
        });


        $('button').click(function(){

            var val = $(this).data('val');
            var string = editor.getSelection();

            switch(val){

                case 'bold': 
                    editor.replaceSelection('<b>' + string + '</b>');
                break;

                case 'code': 
                    editor.replaceSelection('<pre>' + string + '</pre>');
                break;
            }
        });
    });
});

</script>

HTML

<div class="container">

    <div class="row">

        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

            <div class="panel panel-default"  onLoad="text_editor();">

                <div class="panel-heading">
                    <button type="button" data-val="bold" class="btn btn-default">Bold</button>
                    <button type="button" data-val="code" class="btn btn-default ">Code</button>
                </div>

                <div class="panel-body">
                    <textarea id="text-editor" name="text-editor" class="form-control"></textarea>
                </div>

            </div><!-- . / panel -->

        </div><!-- . / col -->

    </div><!-- . / row -->

    <div class="row">

        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div id="question-preview"></div>
        </div>

    </div><!-- . / row -->

</div>  

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How to undo selected / highlighted text when click on button with codemirror

Passing a Value from a URL Parameter to Header:Location redirect

Vote count: 0

Here is what I want to achieve:

1.) opening http://ift.tt/1mNxKQC

2.) should 301 redirect to: http://www.example.com

(TESTING) So far, in out.php this works:

<?php
    header("Location: http://www.example.com");
?>

So I went ahead and did this:

<?php
    header("Location: " . $_GET['url']);
?>

It won't work, I went through all stackoverflow.com articles that i could find but none worked.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Passing a Value from a URL Parameter to Header:Location redirect

Can a WinForms Startup Form Be Used As The Composite Root For The Unity Container

Vote count: 0

I have a WinForms application setup as an N-Layered solution in Visual Studio. I would like to use the first startup form in this WinForms application as the location where my Unity registrations and Resolves take place. This would be right in the initialization step as the form is beginning to startup. If I place the Unity setup here then I won't need to be concerned about passing in parameters to the startup form from a separate project. The startup form is basically the main form of all forms in the WinForms application. All other forms are spawned from the main form either directly or indirectly.

If Unity is setup in the main form, I can register all the interface classes intended to be injected into all other sub forms and project classes here. Would doing this cause any serious problems or would this approach work out fine?

I like this approach because it would mean I don't have to have a separate project created just for the purpose of setting up Unity and having to register all interface classes in that project to be passed to the first startup form.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Can a WinForms Startup Form Be Used As The Composite Root For The Unity Container

Bootstrap tooltip/popover not showing properly

Vote count: 0

I'm using Angular 2 to build my web application. When I try to put a tooltip or popover on an image or button, I get the default-looking tooltip instead of the bootstrap one.

I've tried the basic W3Schools examples and did everything as shown, yet it doesn't work.

I believe my problem lies with the correct imports of the bootstrap.js or jQuery, but other bootstrap items like buttons etc. do work properly.

(I use nodejs to install the necessary files/dependencies -> npm install npm install bootstrap npm install jquery)

index.html

<html>
<head>
    <base href="/"><!--Without this tag, the browser may not be be able to load resources (images, css, scripts) when "deep linking" into the app. Bad things could happen when someone pastes an application link into the browser's address bar or clicks such a link in an email link. -->
    <title>Factory</title>
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="/css/styles.css">

    <script src="node_modules/jquery/dist/jquery.js"></script>
    <script src="node_modules/jquery/dist/jquery.min.js"></script>

    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/angular2/bundles/router.dev.js"></script>
    <script src="node_modules/angular2/bundles/http.dev.js"></script>

    <link rel="stylesheet" href="http://ift.tt/1RrshYi">
    <script src="http://ift.tt/1LdO4RA"></script>
    <script src="http://ift.tt/1D8Hvux"></script>

    <script src="node_modules/bootstrap/js/tooltip.js"></script>

    <script>
        System.config({
            packages: {
                app: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            }
        });
        System.import('app/boot')
                .then(null, console.error.bind(console));
    </script>
</head>
<body>
    <my-app></my-app>
</body>
</html>

page-with-tooltip(.ts)

import {Component} from "angular2/core";
import ... from ...;
import ... from ...;
...

@Component({
    template: `
<div *ngIf="hall" class="container">
    <h2>Detail van hal <small>{{hall.name}}</small></h2>
    <div class="container">
        <div class="hall-box-single">
            <div class="hall-box"
                [style.width]="hall.areaWidth*4"
                [style.height]="hall.areaHeight*4">
                <div class="image-container">
                <div *ngFor="#item of hall.items">
                    <a data-toggle="tooltip" data-toggle="popover" title="Popover title" data-content="Right?">
                    <img [src]="item.image"
                         [style.left]="item.posX"
                         [style.top]="item.posY"/>
                     </a>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        $('[data-toggle="popover"]').popover();
    });
</script>
`})

export class HallDetailComponent implements OnInit {
    ...
}

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Bootstrap tooltip/popover not showing properly

Creating a custom ImageList class with extended image property

Vote count: 0

I would like to replace my existing ImageLists with custom imagelists.

I am trying to make my class compatible with the .NET ImageList so that I don't have to change much code.

            Using g As Graphics = Graphics.FromImage(SomeBitmap)
                g.DrawImage(il.Images(myIndex), 0, 0, 256, 256)
            End Using

The error I'm getting is "There is no overloads for this function.".

I do understand this error, but I wonder if I could perhaps extend the Graphics to accept my clsImageItem.

This is its code:

Public Class clsImageItem

    Public ReadOnly Property [Image] As Image
    Private _sGUID As String

    Public Sub New(uImage As Image, uGUID As String)

        Image = uImage
        _sGUID = uGUID

    End Sub

End Class

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Creating a custom ImageList class with extended image property

How to adjust resolution of space changed image in itk

Vote count: 0

I have 2D dicom image series and I read and put together a 3D image file.Its spacing values are 0.449219 0.449219 1 . Also, Image size is 512*512*25 . So in the z-axis image looks like compressed. When I change spacing values resolution getting worse. How can I extend z-axis without losing in resolution value ? this image is original, and this is scaling changed image.

asked 33 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How to adjust resolution of space changed image in itk

Maven dependency is not found when that dependency is open in a project in the same workspace

Vote count: 0

The title was a bit difficult to form given the issue. Here is a better explanation.

I have 2 projects in an Eclipse workspace, Project A and Project B.

Project A is a maven project that compiles to a jar and I typically run a maven install to deploy it to my local m2 repository.

Project B is also a maven project but is a web application and uses Project A as a dependency. It uses this snippet from the pom to add Project A as a dependency:

    <dependency>
        <groupId>com.sample</groupId>
        <artifactId>sample-consumer</artifactId>
        <version>${sample.version}</version>
    </dependency>

When Project A is OPEN and I run Project B, anytime it tries to reference something from project A it throws a file not found exception.

When Project A is CLOSED and deployed to my maven repo the references from Project B to Project A work as they should.

This is an incredible hassle when I need to make constant changes to Project A. Does anyone have a way to fix this? I've had a scenario like this in the passed run smooth but am not sure of the trick.

If you need to see something more please ask.

asked 40 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Maven dependency is not found when that dependency is open in a project in the same workspace

Primefaces document Viewer how to replace encoding + with %20 in url attribute

Vote count: 0

Primefaces component document viewer is encoding the path to my file in this way:

http://localhost:8080/myproject/resources/Folder+1/pdf/myfile.pdf

And then the file it is not found.

How could I replace the "+" sign with "%20" ? Or how could I change the encoding?

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Primefaces document Viewer how to replace encoding + with %20 in url attribute

change images in menu

Vote count: 0

i need in this code swap (change) image in img tag after hover and click. Im not good in javascript so i need help. If some image is active (clicked) and I click on next image in menu so other images must be change to default. Sorry for my english.

<ul id="ourteam">  
              <li><a data-target="#user1" class="active"><img src="/img/avatars/avatar1.png" data-other-src="/img/avatars/avatar1h.png" /></a></li>
              <li><a data-target="#user2"><img src="/img/avatars/avatar_t.png" /></a></li>
              <li><a data-target="#user3"><img src="/img/avatars/avatar3.png" data-other-src="/img/avatars/avatar3h.png" /></a></li>
              <li><a data-target="#user4"><img src="/img/avatars/avatar4.png" data-other-src="/img/avatars/avatar4h.png" /></a></li>
            </ul>

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



change images in menu

Can't get all data from Yahoo finance API

Vote count: 0

I'm using python pandas in order to get stock/index prices from yahoo finance. I use the web.DataReader([list of stocks], 'yahoo', start, end)

Many of these stocks are working fine. However, one doesn't. My questions is: How can I manage to successfully gather all of them?

The one called ^DJCI is the one that doesn't work. It is available on the website of yahoo and it has data. I can't even get it individually by doing the following:

web.DataReader('^DJCI', 'yahoo', start, end)

I get the following error:

IOError: after 3 tries, Yahoo! did not return a 200 for url 'http://ift.tt/1TM88i2'

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Can't get all data from Yahoo finance API

Pagedown and Angle Brackets not Cooperating

Vote count: 0

I'm trying to use Pagedown to parse markdown (containing code sections) into html.

It mostly works, but I've noticed one strange behavior. If I have this in my markdown:

`ArrayList<String> names = new ArrayList<>();`

The text that displays ends up being this:

ArrayList<string> names = new ArrayList&lt;&gt;();

Notice that the first String is lower-cased, and the second <> is converted into html entities, which are not correctly displayed since they end up inside a code block.

If I look at the markdown that Pagedown "thinks" it's supposed to process, it gets stranger:

`ArrayList<string> names = new ArrayList&lt;&gt;();`</string>

Obviously, it's treating the <String> section of the code text as an html tag, and adding a closing </string> tag. Parsing that markdown produces this html:

<code>ArrayList&lt;string&gt; names = new ArrayList&amp;lt;&amp;gt;();</code>

If I encode the angle brackets ahead of time:

`ArrayList&lt;String&gt; names = new ArrayList&lt;&gt;();`

Then Pagedown simply encodes the html entities as part of the code, which is exactly what I want it to do with the angle brackets:

 <code>ArrayList&amp;lt;String&amp;gt; names = new ArrayList&amp;lt;&amp;gt;();</code>

I just want to be able to throw markdown (containing code sections) into the Pagedown parser and have it output sanitized html. Here is what I'm currently doing:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="Markdown.Converter.js"></script>
<script type="text/javascript" src="Markdown.Sanitizer.js"></script>
<script src="http://ift.tt/13qgtmt"></script>
<script>
    function parseMarkdown(){

        var markdown = $("#markdown").html();        

        console.log("markdown: " + markdown);

        var converter =  new Markdown.getSanitizingConverter();
            var html = converter.makeHtml(markdown);

            console.log("html: " + html);

            $("#markdown").html(html);
    }
    $(parseMarkdown);
</script>
</head>
<body onload="parseMarkdown">
<div id="markdown">
`ArrayList<String> names = new ArrayList<>();`
</div>

</body>

</html>

In real life the markdown is either coming from a database (which was written using the Pagedown editor) or from markdown files (which were written in a basic text editor). Is there an extra step I'm missing? Is the above approach a risk of bad JavaScript being run before Markdown parses it?

asked 3 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Pagedown and Angle Brackets not Cooperating

How do I get a drawable animation of an ImageView to move left and right when I press a button

Vote count: 0

I am using Android Studio trying to get an ImageView object to move left and right when I press a left or right button. My problem is when I want to change directions the animation starts over again from the ImageView's initial position, how can I get the location of the translated object and use the animation on that instead?

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How do I get a drawable animation of an ImageView to move left and right when I press a button

How do you change the color of all of the nodes of a specific name in SpriteKit with Swift

Vote count: 0

I'm trying to change the color of every single instance of a node in SpriteKit. When I try to put it in the update method, it only changes one and not all of them.

override func update(currentTime: CFTimeInterval) {
    if changeColor == true{

        self.enumerateChildNodesWithName("blocks", usingBlock: {
            node, stop in
            block?.color = UIColor.orangeColor()
        })

    }
}

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How do you change the color of all of the nodes of a specific name in SpriteKit with Swift

C# Windows Forms - 3D Plot - Positioning in Space of a Quadcopter

Vote count: 0

I would like to use this on my windows forms application. https://www.youtube.com/watch?v=0KHMaLRbnDM

The problem is that I cant find any proper way to implement something similar to 3d plotting in matlab in c# windows forms.

My application already have the values of x,y,z coordinates , yaw,pitch,roll,etc...

Does anyone know something to I can start?

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



C# Windows Forms - 3D Plot - Positioning in Space of a Quadcopter

jQuery check for window resize triggers toggle to many times

Vote count: 0

I have a jQuery function that I only want to work when the window is smaller then 768px. (this is for a responsive site so I can't just do it for mobile devices)

I have some code that checks for a specific css style only applied when the screen size is less then 768px. Then it hides the menu and toggles the menu when a user clicks on another item. (#mainMenu)

I have the following code:

function checkSize(){
    if ($('#mainLogo').css('float') == 'none') {
        $('.menu-main-menu-container').slideToggle();   
        } else {
        $('.menu-main-menu-container').slideDown();
    }   
}

$('#mainMenu').click(function() {
       checkSize();
});

This code works pretty well except for when users are on a desktop and have the screen smaller then 768px, toggle the menu closed, and then drag the screen wider. It keeps the main menu hidden.

I tried adding this:

$(window).resize(checkSize);

But now when I resize the screen, both smaller and wider, it toggles the menu about 5 times.

Is there a way to fix this? Or maybe a better way to check for the width of the screen so that the toggle only happens when the screen is smaller then 768px? I wish there were media queries for jQuery!

(ps I also tried looking at the window width but it isn't accurate enough)

Thanks!

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



jQuery check for window resize triggers toggle to many times

Yii2 send using SMS

Vote count: 0

Hi i using Twilio to send notification to sms...but i got this error..i already searching to fix this problem but not find a solution..

Error Message:

Services_Twilio_TinyHttpException

SSL certificate problem: self signed certificate in certificate chain

backend\config\main:

'components' => [
    ...
    'sms' => [
        'class' => 'darkunz\yii2sms\Twilio',
        'sid' => '**********'
        'token' => '********',
        'number' => '*********',
    ]
    ...
]

in controller:

Yii::$app->sms->send('+612345678910', 'Hi');

i hope anyone who knows can help me to fix it...

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Yii2 send using SMS

Rails rev assets using Gulp

Vote count: 0

I am reading the guide on this site: http://ift.tt/1urqEkw

and I read the following part:

Rev This is my favorite part of using Gulp. Rev will give you that friendly app-ef62e7.js filename output that Asset Pipeline is famous for. The reason for it is you can cache it forever. New requests will just point to new files. CDNs love this. To get the files to have the hash is pretty easy with Rev.

var rev = require('gulp-rev');

gulp.task('rev', ['less', 'scripts'], function() { return gulp.src(['dist//.css', 'dist//.js']) .pipe(rev()) .pipe(gulp.dest('dist')) .pipe(rev.manifest()) .pipe(gulp.dest('dist')); }); view rawgulpfile.js hosted with ❤ by GitHub Now the filename has the hash appended to it! Note the digest I generate as well; that looks like the following:

{ "app.css": "app-1c1d3237.css", "app.js": "app-26ad0c3f.js" } view rawrev-manifest.json hosted with ❤ by GitHub Here is where a bit of custom code would come into play. When you generate your index.html (or wherever else you reference the CSS/JS) you will have to swap out the URL for the one in the digest file. Should only be a matter of parsing this JSON file in your framework of choice, or having Gulp rewrite your index.html to replace the CSS/JS include with the correct filename.

This is all well and good and sounds fine to me but if I do that and Gulp injects the new filenames for my main css and js files then my git version control system is going to pick up this as a change EVERY SINGLE TIME I update my assets.

How do people deal with this?

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Rails rev assets using Gulp

Python - Get windows folder ACL permissions

Vote count: 0

I am looking for an example to get a folder ACL permissions. I need the result to be like: domain\username - FullControl, domain\username Modify

Thank you !

asked 29 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Python - Get windows folder ACL permissions

Python Threading not stopping

Vote count: 0

first try at threading in python, the threading is working after following a post on Stack however I can't stop the thread with ctrl-c despite having a terminate method in my class called with a keyboard interrupt.

Basically I'm polling a temp sensor in the background and using a thread to do that whilst the main body of the code is watching GPIO inputs, everything is working fine, its just threading thats baffling me/

(there's intention overkill re print messages so I can understand where its going wrong etc)

class GetClimate(threading.Thread):
  def __init__(self):
    self._running = True
    print "Data Collection STARTED"
  def terminate(self):
    self._running = False
    print "Data Collection ENDED"
  def run(self):
    while self._running is True:
      ts = time.time()
      global GARAGE_HUM, GARAGE_TEMP
      timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
      GARAGE_HUM, GARAGE_TEMP = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 4)
      if GARAGE_HUM is not None and GARAGE_TEMP is not None:
        print timestamp + " - Temperature: %.1f c" % GARAGE_TEMP
        print timestamp + " - Humidity:    %.1f %%" % GARAGE_HUM
        time.sleep(5) # seconds between sample

#---------Start Getting Climate data------------

def StartClimate():
    c = GetClimate()
    t = threading.Thread(target=c.run)
    t.start()
    print "Started Climate"
#--------Stop Climate Data----------------------
def StopClimate():
    print "Called Climate stop .."
    c = GetClimate()
    c.terminate()
    print "Stopped Climate"

When ctrl-c is used its calling the StopClimate() function OK as it outputs:

Data Collection STARTED
Started Climate
..Ready
2016-01-09 20:48:45 - Temperature: 24.8 c
2016-01-09 20:48:45 - Humidity:    51.9 %
Shutdown requested...exiting
Called Climate stop ..
Data Collection STARTED
Data Collection ENDED
Stopped Climate
^C2016-01-09 20:48:51 - Temperature: 24.8 c
2016-01-09 20:48:51 - Humidity:    51.9 %
2016-01-09 20:48:57 - Temperature: 24.7 c
2016-01-09 20:48:57 - Humidity:    51.8 %

.... as you can see the thread is still polling.

asked 33 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Python Threading not stopping

Search replace patterns in a Python list

Vote count: 0

I have a list of Rubik's Cube movements and a dictionary of shortcuts like this :

mvts = ['U', 'U', 'R', 'Ri', 'L2', ...]
shortcuts = {'UU' : 'U2', 'RRi' : '', ...}

What I'm trying to do is applying a "search and replace" on the mvts list based on the contents of shortcuts.

Here is what the result would be in the example :

mvts = ['U2', 'L2', ...]

I'm using Python3 and I can't use a library that doesn't come with Python from scratch.

I'm stuck. I can do this with some regex on a String but I don't see how to make this search quick on my list.

asked 35 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Search replace patterns in a Python list

inline assembly error while compiling linux kernel 2.4.0

Vote count: 0

I am trying to compile linux kernel 2.4.0 on Ubuntu 15.10 32-bit. I receive this errors while building:

linux/include/asm/checksum.h:161:2: error: missing terminating " character linux/include/asm/checksum.h:173:3: error: missing terminating " character ...

What gcc is complaining are the quotations in the inline assembly:

static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
                                                     struct in6_addr *daddr,
                                                     __u32 len,
                                                     unsigned short proto,
                                                     unsigned int sum)
{
        __asm__("
                addl 0(%1), %0
                adcl 4(%1), %0
                adcl 8(%1), %0
                adcl 12(%1), %0
                adcl 0(%2), %0
                adcl 4(%2), %0
                adcl 8(%2), %0
                adcl 12(%2), %0
                adcl %3, %0
                adcl %4, %0
                adcl $0, %0
                "
                : "=&r" (sum)
                : "r" (saddr), "r" (daddr),
                  "r"(htonl(len)), "r"(htonl(proto)), "0"(sum));

        return csum_fold(sum);
}

I am not sure why this happens. Is it because incompatible gcc version? My current gcc version is gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010.

asked 37 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



inline assembly error while compiling linux kernel 2.4.0

Backbone render element

Vote count: 0

I try to do some exercise in Backbone, but I have problems with rendering of view elements. It would be great to get some idea solving my problem. Any help is welcome!

Here is the modules which I implemented:

(The Basic idea is from here)

Module: keyvalue.js

    define(function (require) {
    "use strict";
    var $                   = require('jquery'),
        _                   = require('underscore'),
        Backbone            = require('backbone');

    // Keyvalue Name Space
    window.Keyvalue = {
        Models: {},
        Collections: {},
        Views: {}
    };

    // Keyvalue Data Model
    Keyvalue.Models.Data = Backbone.Model.extend({
        defaults: {
            key: 'NRW',
            value: 'Nordrhein-Westfalen'
        },
        initialize: function(){
        }
    });

    // Keyvalue Data Collection Class
    Keyvalue.Collections.Data = Backbone.Collection.extend({
        model: Keyvalue.Models.Data
    }); 
    return Keyvalue;    
});

Module: keyvalue_list.js

define(function (require) {
"use strict";
var $                   = require('jquery'),
    _                   = require('underscore'),
    Backbone            = require('backbone'),
    Keyvalue_line       = require('app/views/Keyvalue_line'),
    tpl                 = require('text!tpl/keyvalue_list.html'),
    template            = _.template(tpl);      

// Keyvalue Name Space
window.Keyvalue = {
    Models: {},
    Collections: {},
    Views: {}
};

// Keyvalues View List
Keyvalue.Views.List = Backbone.View.extend({
    tagName: 'ul',

    initialize: function() {
        this.collection.on('add', this.addOne, this);
    },

    render: function() {
        this.collection.each(this.addOne, this);
        return this;
    },

    addOne: function(keyvalue) {
        var keyvalueLine = new Keyvalue_line.Views.Line({ model: keyvalue });
        this.$el.append(keyvalueLine.render().el);
    }
});
return Keyvalue;
});

Module: keyvalue_line

define(function (require) {
"use strict";
var $                   = require('jquery'),
    _                   = require('underscore'),
    Backbone            = require('backbone'),
    tpl                 = require('text!tpl/keyvalue_line.html'),
    template            = _.template(tpl);

// Keyvalue Name Space
window.Keyvalue = {
    Models: {},
    Collections: {},
    Views: {}
};
// Keyvalues View Line
Keyvalue.Views.Line = Backbone.View.extend({
    tagName: 'li',

    initialize: function(){
        this.model.on('change', this.render, this);
        this.model.on('destroy', this.remove, this);
    },

    events: {
        'click .edit': 'editKeyvalue',
        'click  .delete': 'destroyKeyvalue'
    },

    editKeyvalue: function() { 
        var newValue = prompt("Please enter the new value", this.model.get('value'));
        if(newValue){
            this.model.set('value', newValue);
        }   
    },

    destroyKeyvalue: function(){
        this.model.destroy();       
    },

    remove: function(){
        this.$el.remove();
    },

    render: function() {
        //alert(JSON.stringify(this.model.toJSON()));<-- ok
        this.$el.html(template(this.model.toJSON()));
        return this;
    }
}); 
return Keyvalue;
});

Module where I instantiate: keyvalue.js

define(function (require) {
"use strict";
var $                   = require('jquery'),
    _                   = require('underscore'),
    Backbone            = require('backbone'),
    Keyvalue_list       = require('app/views/Keyvalue_list'),
    Keyvalue            = require('app/models/keyvalue'),
    tpl                 = require('text!tpl/keyvalue_list.html'),
    template            = _.template(tpl);

return Backbone.View.extend({
    initialize: function() {
        this.kvArray = [{key: 'BY',value: 'Bayern'},{key: 'RP',value: 'Rheinland-Pfalz'},{key: 'NRW', value: 'Nordrhein-Westfalen'}];
    },

    render: function () {
        this.$el.html(template());  
        this.keyvalue_table = new Keyvalue.Collections.Data(this.kvArray);
        var listView = new Keyvalue_list.Views.List({ collection: this.keyvalue_table });
        this.$el.append(listView.render().el);
        return this;
    }
 });
 });

Template: keyvalue_line.html

<script id="keyvalue_table" type="text/template">
<strong><%= key %></strong>(<%= value %>)

Template: keyvalue_list.html

<form id="keyvaluelist" action="">
<input type="text" placeholder="Key"/>
<input type="submit" placeholder="Add Key-Value"/>

Where I place the result: index.html

...
    <div class="row placeholders">  
       <div id="keyvaluelist">  KEYVALUE-LIST  </div>
    </div>
...

asked 44 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Backbone render element

IIS not running ASP.net 5 RC2 MVC 6 web application

Vote count: 0

IIS from Visual Studio will not launch my application. It seems as if Visual Studio is trying to build my project with the incorrect DNX version. However, under my application profile it has the correct solution DNX version of 1.0.0-rc2-16357. When I attempt to launch the application through IIS Express, the app throws up a blank web page and it immediately stops executing with 'dnx.exe' has exited with code 1 (0x1).' There are no exceptions when this happens. However, I am able to launch it through the command line using

dnvm upgrade -u
dnu restore 
dnx ef migrations add initial
dnx ef database update
dnx web

My project.json:

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
        "EntityFramework.Commands": "7.0.0-*",
        "EntityFramework.Core": "7.0.0-*",
        "EntityFramework.Sqlite": "7.0.0-*",

        "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
        "Microsoft.AspNet.Mvc": "6.0.0-*",
        "Microsoft.AspNet.HttpOverrides": "1.0.0-*",
        "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*",
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
        "Microsoft.AspNet.StaticFiles": "1.0.0-*",

        "Microsoft.Extensions.Logging.Console": "1.0.0-*",
        "Microsoft.Extensions.Logging.Debug": "1.0.0-*"
    },

    "commands": {
        "web": "LeafApi",
        "ef": "EntityFramework.Commands"
    },

    "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
    }
}

asked 53 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



IIS not running ASP.net 5 RC2 MVC 6 web application

Android TextView go over the toolbar

Vote count: 0

i have problem that when i am using a text view the text from the list view come over my toolbar i don't know what to do , please help me because i want to use later to toolbar for make search filter . thanks to all the helpers if you need me to add my style file or something please let me know !

enter image description here

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Android TextView go over the toolbar

Defining TypeScript generic type with new()

Vote count: 0

I want to have function like:

createEntity<TEntity>(): TEntity {
    return new TEntity();
}

but it doesn't allow to do this. In C# we could write:

void TEntity CreateEntity<TEntity>() where TEntity : new()

How can I do this in TypeScript

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Defining TypeScript generic type with new()

cntlm keeps on prompting for password

Vote count: 0

cntlm-0.92.3-8.fc23.x86_64

cntlm -h says that I can specify password on command line

-p  <password>
    Account password. Will not be visible in "ps", /proc, etc.

but when I invoke it with

cntlm -H -p mypass -u myuser -d mydomain

it prompts me again

cntlm -H -u myuser -d mydomain -p mypass
Password: 
PassLM          FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
PassNT          FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 
PassNTLMv2      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF    # Only for user 'myuser', domain 'mydomain'

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



cntlm keeps on prompting for password

Apache 2.4 + FPM + Wordpress Multisite: URL Rewrite not working in admin

Vote count: 0

I just moved a Wordpress multi-site from a Apache 2.4 Prefork + mod_php to a new server with Apache 2.4 Event + php-fpm.

The site is working well on the frontend and it is a lot faster then before due to the CGI, but... the Wordpress administration panel is working just for the main site (and network administration). The admin area for the second site is no more working, but the frontend is working great.

Examples

I tried to debug the rewrites, but the unique log I have (also using Debug Level 8) is

[proxy_fcgi:error] [pid 13700:tid 140381047965440] [client X.X.X.X:54354] AH01071: Got error 'Primary script unknown\n', referer: http://ift.tt/1ObflGI

Follwing my configurations. Any help appreciated. Thank you.

Virtual Host

<VirtualHost *:80>
ServerName www.example.com
DocumentRoot "/srv/www/http://ift.tt/18GT7ew"
<IfModule mpm_event_module>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/srv/www/example.com/public_html/$1
</IfModule>
<Directory "/srv/www/http://ift.tt/18GT7ew">
AllowOverride all
Require all granted
</Directory>
ErrorLog /srv/www/http://ift.tt/1b5HsIJ
TransferLog /srv/www/http://ift.tt/1DCy0VI
</VirtualHost>

.htaccess

<Files "xmlrpc.php">
Order Allow,Deny
Deny from all
</Files>

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(admin|content|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+]/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Apache 2.4 + FPM + Wordpress Multisite: URL Rewrite not working in admin

Trying to figure out why when writing to file, the last character written is being duplicated when cout looks fine on display

Vote count: 0

Question = Trying to figure out why the write to file for

 myfile.open ("Crypt103Data.txt", ios::out | ios::app);
 myfile <<tab2[code1];
 myfile.close();

is writing the last character twice to Crypt103Data.txt when the cout which also runs for the same iterations within the while loop displays proper without the extra character write appended to file?

If you enter something like Hello_World you might see something like r$cc7fq7UcX depending on what seed value to entered which gives the output a unique output that is dependent on the seed key. While r$cc7fq7UcX is observed correctly on the screen below the Hello_World , what is written to file is r$cc7fqUcXX where the last character is written twice and it should only be r$cc7fqUcX . Not sure why this happens when the cout print to display and file write appended happens for the same iterations within the while loop. Instead of placing a band aid in to trim the last character from the file after each line is written, there must be a fix for this odd bug that someone here might be able to point out. Maybe I am using sloppy programming that is causing for this to occur. I am using the Bloodshed Dev c++ 4.9.9.2 IDE btw

#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process v1.00
// 1/5/2016 - Added characters , and ; to supported characters which were missing from v1.01
// 1/8/2015 - Source code trash cleanup & offset band aid removed for IF statement logic +1 array offset v1.02
// 1/8/2015 - Added write to file for coded data storage eliminating need to copy/paste output to a text file v1.03
using namespace std;

int main(int argc, char *argv[])
{

    int seed1=0;
    int code1=0;
    int run=1;
    int again=1;
    int test=1;
    char ch1;
    char ch2;


        while(again==1){



    cout<<" Crypt Version 1.03\n\n";
    cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
    cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
    cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
    cin >> seed1; // Input user seed
    cout<<"\n\n"<<"Crypt String Key =\n\n";

              ofstream myfile;
  myfile.open ("Crypt103Key.txt", ios::out | ios::app);
  myfile <<seed1<<"\n";
  myfile.close();






    //Initialize Valid Characters for String Shuffle Output
    //Note Bug corrected with blank space for \ by use of escape character proceeding
    string str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_-+=?<>:\\/~.,;";



    srand(seed1); // Allows user custom seeded starting algorithm position for random

    random_shuffle(str.begin(), str.end()); // Shuffle the string
    cout << str << "\n\n\n"; // Output the shuffle sequence


        //Pass String Output into an array to pair up pointer value with associated character

    string tmp = str; //Pass str output to string tmp
    char tab2[128]; // Memory Allocation for array population
    strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
    tab2[sizeof(tab2) - 1] = 0;


        cout<<"Enter Info to Crypt in correct case\n";
        cout<<"To Exit Inner Program enter  ( ` ) \n\n\n";

    while(run==1){

    cin>>ch1;

    if (ch1=='A'){
                code1=0;
                }
    else if (ch1=='B'){
         code1=1;
         }
    else if (ch1=='C'){
         code1=2;
         }
    else if (ch1=='D'){
         code1=3;
         }
    else if (ch1=='E'){
         code1=4;
         }
    else if (ch1=='F'){
         code1=5;
         }
    else if (ch1=='G'){
         code1=6;
         }
    else if (ch1=='H'){
         code1=7;
         }
    else if (ch1=='I'){
         code1=8;
         }
    else if (ch1=='J'){
         code1=9;
         }
    else if (ch1=='K'){
         code1=10;
         }
    else if (ch1=='L'){
         code1=11;
         }
    else if (ch1=='M'){
         code1=12;
         }
    else if (ch1=='N'){
         code1=13;
         }
    else if (ch1=='O'){
         code1=14;
         }
    else if (ch1=='P'){
         code1=15;
         }
    else if (ch1=='Q'){
         code1=16;
         }
    else if (ch1=='R'){
         code1=17;
         }
    else if (ch1=='S'){
         code1=18;
         }
    else if (ch1=='T'){
         code1=19;
         }
    else if (ch1=='U'){
         code1=20;
         }
    else if (ch1=='V'){
         code1=21;
         }
    else if (ch1=='W'){
         code1=22;
         }
    else if (ch1=='X'){
         code1=23;
         }
    else if (ch1=='Y'){
         code1=24;
         }
    else if (ch1=='Z'){
         code1=25;
         }
    else if (ch1=='a'){
         code1=26;
         }
    else if (ch1=='b'){
         code1=27;
         }
    else if (ch1=='c'){
         code1=28;
         }
    else if (ch1=='d'){
         code1=29;
         }
    else if (ch1=='e'){
         code1=30;
         }
    else if (ch1=='f'){
         code1=31;
         }
    else if (ch1=='g'){
         code1=32;
         }
    else if (ch1=='h'){
         code1=33;
         }
    else if (ch1=='i'){
         code1=34;
         }
    else if (ch1=='j'){
         code1=35;
         }
    else if (ch1=='k'){
         code1=36;
         }
    else if (ch1=='l'){
         code1=37;
         }
    else if (ch1=='m'){
         code1=38;
         }
    else if (ch1=='n'){
         code1=39;
         }
    else if (ch1=='o'){
         code1=40;
         }
    else if (ch1=='p'){
         code1=41;
         }
    else if (ch1=='q'){
         code1=42;
         }
    else if (ch1=='r'){
         code1=43;
         }
    else if (ch1=='s'){
         code1=44;
         }
    else if (ch1=='t'){
         code1=45;
         }
    else if (ch1=='u'){
         code1=46;
         }
    else if (ch1=='v'){
         code1=47;
         }
    else if (ch1=='w'){
         code1=48;
         }
    else if (ch1=='x'){
         code1=49;
         }
    else if (ch1=='y'){
         code1=50;
         }
    else if (ch1=='z'){
         code1=51;
         }
    else if (ch1=='1'){
         code1=52;
         }
    else if (ch1=='2'){
         code1=53;
         }
    else if (ch1=='3'){
         code1=54;
         }
    else if (ch1=='4'){
         code1=55;
         }
    else if (ch1=='5'){
         code1=56;
         }
    else if (ch1=='6'){
         code1=57;
         }
    else if (ch1=='7'){
         code1=58;
         }
    else if (ch1=='8'){
         code1=59;
         }
    else if (ch1=='9'){
         code1=60;
         }
    else if (ch1=='0'){
         code1=61;
         }
    else if (ch1=='!'){
         code1=62;
         }
    else if (ch1=='@'){
         code1=63;
         }
    else if (ch1=='#'){
         code1=64;
         }
    else if (ch1=='$'){
         code1=65;
         }
    else if (ch1=='%'){
         code1=66;
         }
    else if (ch1=='^'){
         code1=67;
         }
    else if (ch1=='&'){
         code1=68;
         }
    else if (ch1=='*'){
         code1=69;
         }
    else if (ch1=='('){
         code1=70;
         }
    else if (ch1==')'){
         code1=71;
         }
    else if (ch1=='_'){
         code1=72;
         }
    else if (ch1=='-'){
         code1=73;
         }
    else if (ch1=='+'){
         code1=74;
         }
    else if (ch1=='='){
         code1=75;
         }
    else if (ch1=='?'){
         code1=76;
         }
    else if (ch1=='<'){
         code1=77;
         }
    else if (ch1=='>'){
         code1=78;
         }
    else if (ch1==':'){
         code1=79;
         }
    else if (ch1=='\\'){ // Escape Character \ needed to allow \ check
         code1=80;
         }
    else if (ch1=='/'){
         code1=81;
         }
    else if (ch1=='~'){
         code1=82;
         }
    else if (ch1=='.'){
         code1=83;
         }
    else if (ch1==','){
         code1=84;
         }
    else if (ch1==';'){
         code1=85;
         }
    else if (ch1=='\`'){ //Escape Character \ before ` to exit
         run=0; //Run = False at 0 and leaves while loop
         }
    else {
         cout<<"Invalid Input = No Match\n\n";
         }
         cout<<tab2[code1];




    myfile.open ("Crypt103Data.txt", ios::out | ios::app);
  myfile <<tab2[code1];
  myfile.close();

         }// end inner while loop
         //Add line return in file to seperate the data per line
             myfile.open ("Crypt103Data.txt", ios::out | ios::app);
  myfile <<"    "<<"\n";
  myfile.close();
  test=1;
  while(test==1){
          system("CLS");
          cout<<"Enter Y to continue or N to end \n\n\n";
          cin>>ch2;
          if (ch2=='N'||ch2=='n'){
                again=0;
                test=0;
                }
    else if (ch2=='Y'||ch2=='y'){
         again=1;
         test=0;
         run=1;
         system("CLS");
         }
    else {
         cout<<"Invalid Input, please choose Y or N \n\n";
         test=1;
         }   
         } 


} // end outter while loop

    system("CLS");
    system("PAUSE");
    return EXIT_SUCCESS;
}

asked 54 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Trying to figure out why when writing to file, the last character written is being duplicated when cout looks fine on display

Can I define a member function in a seperate source file to the class source file?

Vote count: 0

I have a source for a class in c++ that has many member functions. I am trying to decide whether or not to put a portion of the member function definitions in another source.

If I do, is this likely to drastically effect compilation and/or execution of the program?

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Can I define a member function in a seperate source file to the class source file?

DataGridView: c# generic UserDeletingRow for multiple grids on same form

Vote count: 0

I have several dgvs on a single form. They all have bound data source. They all need to have the ability to "soft" delete rows (not really delete them, but mark the row for deletion and hide it on the grid). The delete will happen at a later date.

I do have a filter on the on the grid: hiatusBindingSource.Filter = "IsDeleted = false"; But I am not sure how to apply the filter after I set the "delete" flag so I came up with the following code to handle a specific dgv.

I want to just have one generic sub to handle all of the dgvs. (I have multiple forms with the same issue.)

        private void dgvHiatus_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
    {
        e.Cancel = true;
        hiatusBindingSource.SuspendBinding();
        e.Row.Visible = false;
        hiatusBindingSource.ResumeBinding();
        ((Hiatus)e.Row.DataBoundItem).IsDeleted = true;
        SetFormMode(Globals.FormStatusMode.Save);
    }

TIA

asked 52 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



DataGridView: c# generic UserDeletingRow for multiple grids on same form

VB6 Data Report Shape Command using Stored Procedure

Vote count: 0

I'm creating a VB6 Data Report, I have two stored procedures in SQL Server database. one contains multiple union Statements another another has several Joins. i need the result set from both these procedures to appear in my data report.

please any suggestions i have tried every possible way i know of.

asked 58 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



VB6 Data Report Shape Command using Stored Procedure

sending raw byte buffer post with curl c++

Vote count: 0

I am trying to figure out how can i send in C++ using the curl easy, a BYTE[100] buffer, which might contain 0x00 bytes, to a POST field to a PHP script. I'm also in need in using the HTML compression technique.

Prior this, i was doing sprintf("%02X") on each bytes so i could send them in letters, but now i need to minimize the network traffic in order to improve the API response time.

I tried on google but so far no resources that is close to my question.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



sending raw byte buffer post with curl c++

How can I create MappedColumnType for Map[K, V] type?

Vote count: 0

How can I create MappedColumnType for Map[K, V] type ? I didn't have success with creating generic mapper. But I tried creating mapper for Map[String, String] that is defined like this (for the sake of example only):

implicit val TestColumnType = MappedColumnType.base[Map[String, String], String](
  { obj => obj.toString }, { str => Map[String, String]() }
)

in my Table class column is defined as

def abstrct = column[Option[Map[String, String]]]("abstract")

I get following compilation error

Error:(130, 54) could not find implicit value for parameter tt: slick.ast.TypedType[Option[Map[String,String]]]
    def abstrct = column[Option[Map[String, String]]]("abstract") 
                                                     ^

What am I missing ? My mappers for simple types work fine.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How can I create MappedColumnType for Map[K, V] type?

Scale or increase a number within a given range while staying within the range

Vote count: 0

Given the range 0 to 99, I have 2 inputs: A and B which can be any number within that range.

However, I wish to increase or boost A so that it will have a higher value than initially, yet staying within the range.

I know I can just arbitrarily add to it or multiply it by a factor, then just limiting it back down to be in range, but I'd like it to be more logarithmic(?) So while inputs of 0 and 99 would stay as they are, lower values will receive less of an increase while higher values will receive more.

Basically if the inputs were something like decibel values, all I'd have to do is multiply it. But if they're linear?

asked 54 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Scale or increase a number within a given range while staying within the range

How to get exact events of scrolled to top and bottom in scrollview

Vote count: 0

I tried many ways explained around here on stackoverflow.But i am still not able to perfectly get each of the events in scrollview.

What i intend to do is change text in an edittext (wrapped inside scrollview) when top or bottom is reached so that large files can be loaded.

        public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            View view = (View) scrollView.getChildAt(scrollView.getChildCount() - 1);
            int diff = (view.getBottom() - (scrollView.getHeight() + scrollView.getScrollY()));

            // if diff is zero, then the bottom has been reached
            if (diff == 0) {
                if(index<texts.size()-1){
                    scrollView.scrollTo(0,0);
                    index++;
                    mInput.setText(texts.get(index));
                }
            }
                // do stuff similarly for top position reached
        }

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How to get exact events of scrolled to top and bottom in scrollview

Sort array of buttons programmatically in c#

Vote count: 0

I have a big number of buttons added programatically by user. Buttons are created by x and y number (user inputs them). For each x there is an y button. So, if my x number is 2, and y number is 3 then I will have buttons named and inserted on form like:

enter image description here

Now, how can I, using two FOR statements, position buttons on the form like: enter image description here

This is my code so far:

int left = 50;
int top = 50;
int all_zd=x*y;
        Button[] btn_arr = new Button[all_zd];
         for (int i = 1; i <=y; i++ ) 

                    {
                        for (int j = 1; j <= x; j++)
                        {
                            //Button btn = new Button();
                            btn_arr[j] = new Button();
                            {
                                btn_arr[j].Name = j.ToString() + "t" + i.ToString();
                                btn_arr[j].Text = j.ToString() + "ff" + i.ToString();
                                btn_arr[j].Height = 20;
                                btn_arr[j].Width = 50;
                                btn_arr[j].Location = new Point(left,top);
         top += btn_arr[j].Height + 2; 
        this.Controls.Add(btn_arr[j]);}}

maybe if statement?

if ((i == 1 && j % x == 1) top+= btn_arr[j].Height + 2;

Please, help, I'm really having trouble with this. Thank you in advance

asked 52 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Sort array of buttons programmatically in c#

Mongo query to check whether today's date is between 2 others

Vote count: 0

I'm trying to query my db to find collections where today's date lies between dates.start and dates.end.

I'm storing the dates in unix time and using moment().valueOf() to get the current unix time.

                        "dates.startDate":{
                            $lte: moment().valueOf()
                        },
                        "dates.endDate":{
                            $gte: moment().valueOf()
                        }

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Mongo query to check whether today's date is between 2 others

Shooting at an object moving on a circular path

Vote count: 0

enter image description here

Im firing a ball at the car who's moving in a circular path, both the ball and the car have constant velocities. I want the ball to move in a straight line towards where the car will be as described in the picture. I want a formula for the red line. (Hope this makes some kind of sense!) Thanks in advance

asked 40 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Shooting at an object moving on a circular path