-
Posts
187 -
Joined
-
Last visited
Posts posted by Lukeidiot
-
-
I am trying to make this complicated JavaScript into a more simple, workable approach.Here is a link to the full source code:
I am trying to accomplish the following stats:
End Goal: Calculate Profit for Roll High and Roll LowHere is the function I believe is responsible for calculating:namespace("Rollin.Casino.Dice.Stats", function() {
var t, e;
return t = namespace.use("Rollin.Casino.Dice.Dice"), e = function() {
function e(t, e) {
this.number = t, this.dice = e
}
return e.prototype.decimal = 5, e.prototype.getData = function(e, n, r) {
var i, o, s, a, u;
switch (r > t.MAX_NUMBER - 1 && (r = t.MAX_NUMBER - 1), r < t.MIN_NUMBER + 1 && (r = t.MIN_NUMBER + 1), i = this.dice.getFee(), n) {
case t.PREDICTION_BIGGER:
o = (100 - i) / (t.MAX_NUMBER - r), s = t.MAX_NUMBER - r;
break;
default:
o = (100 - i) / r, s = r
}
return a = e * o, u = a - e, a > 99999 && (a = 99999), u > 99999 && (u = 99999), a = this.number.floorDecimal(a, this.decimal), u = this.number.floorDecimal(u, this.decimal), this.number.isNaN(a) && (a = 0), this.number.isNaN(u) && (u = 0), {
multiplier: o,
odds: s,
payout: a,
profit: u
}
}, e
}()
}),Here is the same function being used:t.prototype.changeStats_ = function() {
var t, n, r, i;
return t = this.dice.betAmount, i = this.dice.betNumber, n = this.stats.getData(t, e.PREDICTION_BIGGER, i), r = this.stats.getData(t, e.PREDICTION_SMALLER, i), this.element.find(".stats.high .profit").text(n.profit), this.element.find(".stats.high .odds").text(n.odds + "%"), this.element.find(".stats.low .profit").text(r.profit), this.element.find(".stats.low .odds").text(r.odds + "%")
}So, how can I make a simple function where I can calculate the profit by using somethingsuch as this: calculateRollHighProfile(betsize, predictionNumber, houseEdge);Live example: https://rollin.ioPlease note: Profits are affected by house edges below:
-
Well then, good luck. I'm sure you'll eventually arrive at the formula I told you.
[edit] Maybe you're getting thrown off because your numbers are wrong? When I enter 5/88 on their site I get 40/0.625. Not the 40.01818/0.62727 in your screenshot. I don't know how you got those but they're wrong.
It's also possible you didn't notice that the random number range is 0-99 and your choice must be 1-98; that's where the house advantage comes in.
[edit 2] And one more thing: the odds of winning/losing in the formula do not include the... I don't know what it's called, but they don't include the number that you automatically lose with. Since you always lose only on your own number, odds of winning + odds of losing = 99%. Yeah, math.
I think our numbers are different because there are "levels" based on how much you have wagered. For instance I am level 3, and my house edge is only 0.96%. I believe level 1 (your level) house edge is 0.99%.
-
Those aren't the numbers I'm seeing.
It should be basic gambling math: expected profit = bet * odds of losing / odds of winning.
Yes, my head hurts after using lots of math, but here lies to key:
- namespace("Rollin.Casino.Dice.Stats", function() {
- var t, e;
- return t = namespace.use("Rollin.Casino.Dice.Dice"), e = function() {
- function e(t, e) {
- this.number = t, this.dice = e
- }
- return e.prototype.decimal = 5, e.prototype.getData = function(e, n, r) {
- var i, o, s, a, u;
- switch (r > t.MAX_NUMBER - 1 && (r = t.MAX_NUMBER - 1), r < t.MIN_NUMBER + 1 && (r = t.MIN_NUMBER + 1), i = this.dice.getFee(),n) {
- case t.PREDICTION_BIGGER:
- o = (100 - i) / (t.MAX_NUMBER - r), s = t.MAX_NUMBER - r;
- break;
- default:
- o = (100 - i) / r, s = r
- }
- return a = e * o, u = a - e, a > 99999 && (a = 99999), u > 99999 && (u = 99999), a = this.number.floorDecimal(a, this.decimal), u= this.number.floorDecimal(u, this.decimal), this.number.isNaN(a) && (a = 0), this.number.isNaN(u) && (u = 0), {
- multiplier: o,
- odds: s,
- payout: a,
- profit: u
- }
- }, e
- }()
- }),
Full code: http://paste.ubuntu.com/16651803/I just can't seem to quite figure out the correct formula -
-
Hello Math Gods of phpfreaks.
I am in need of a .... formula....
Let's inspect the outcomes..
As we can see, we have the BET SIZE (5), PREDICTION (88) which gives us our profits 40.01818 and 0.62727
So my question is: how do we get the Roll High Profits(40.01818), and Roll Low Profits(0.62727) from BET SIZE and PREDICTION?
Anyone got a php function/formula for this?
Or just a general math formula? (for a live example visit: https://rollin.io)
-
Give this a shot. Without a datadump I couldnt test it.
SELECT u.username, u.email, u.`password`, m.message, g.group_id FROM users AS u INNER JOIN messages AS m ON m.username = u.username INNER JOIN message_group AS g ON g.username = m.username GROUP BY g.group_id ORDER BY m.`timestamp` ASC
I dont think this is working correctly.
Im willing to paypal you some money if you could help a bit more. Skype: Lukecode
-
Give this a shot. Without a datadump I couldnt test it.
SELECT u.username, u.email, u.`password`, m.message, g.group_id FROM users AS u INNER JOIN messages AS m ON m.username = u.username INNER JOIN message_group AS g ON g.username = m.username GROUP BY g.group_id ORDER BY m.`timestamp` ASC
Can you explain how I would use this in a while loop a bit? I added WHERE u.username = '$username' as well.
for example: $row['m.message']; ?
-
Here my code that will display all chat message groups and messages ORDERED BY when the group was created.
I am trying to instead order the message_group list by last message received instead (exactly how imessage or any text message works)
<?php $sql_messages = mysqli_query($connect, "SELECT DISTINCT group_id FROM message_group WHERE username = '$username' || recipients = '$username' ORDER BY id DESC;"); $num_messages = mysqli_num_rows($sql_messages); if($num_messages == 0){ ?> <div id="messagegroups"> <div align="center" style="padding: 5px;" id="nomsg">You have no messages at this time.</div> <div id="messagegroupholder"> </div> <?php } else { ?> <div id="messagegroups"> <?php while($row_messages = mysqli_fetch_assoc($sql_messages)){ ?> <?php $snm = mysqli_query($connect, "SELECT * FROM message_group WHERE group_id = '$row_messages[group_id]' ORDER BY id DESC"); $rm = mysqli_fetch_assoc($snm); $nm = mysqli_num_rows($snm); $ur = mysqli_query($connect, "SELECT * FROM users WHERE username = '$rm[recipients]' ORDER BY id DESC;"); $rr = mysqli_fetch_assoc($ur); $um = mysqli_query($connect, "SELECT * FROM messages WHERE group_id = '$row_messages[group_id]' ORDER BY id DESC;"); $rrr = mysqli_fetch_assoc($um); ?> <div id="messagegroupholder"> <div class="qo cj ca js-msgGroup groupclick" id="msg" data-id="<?php echo $rm['group_id']; ?>"> <a class="b"> <div class="qf"> <span class="qj"> <img class="cu qh" src="./img/<?php echo $rr['image']; ?>" style="height: 42px; width: 42px;"> </span> <div class="qg"> <strong><?php echo $rr['username']; ?></strong> and <strong><?php echo $nm - 1 ?> others</strong> <div class="aof"> <?php echo substr($rrr['message'], 0, 60); ?> … </div> </div> </div> </a> </div> </div> <?php } ?> <?php } ?> </div>
MySQL Structure:
-- -------------------------------------------------------- -- -- Table structure for table `messages` -- CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(100) NOT NULL, `message` text NOT NULL, `ipaddress` varchar(100) NOT NULL, `timestamp` int(11) NOT NULL, `group_id` varchar(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=318 ; -- -------------------------------------------------------- -- -- Table structure for table `message_group` -- CREATE TABLE IF NOT EXISTS `message_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(100) NOT NULL, `recipients` varchar(255) NOT NULL, `group_id` varchar(20) NOT NULL, `ipaddress` varchar(100) NOT NULL, `timestamp` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=82 ; -- -- Table structure for table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `user_level` int(11) NOT NULL DEFAULT '0', `name` varchar(100) NOT NULL, `image` varchar(100) NOT NULL DEFAULT 'default.png', `profile_background` varchar(255) NOT NULL DEFAULT 'default_background.png', `description` varchar(255) NOT NULL, `went_to_school` varchar(100) NOT NULL, `worked_at` varchar(100) NOT NULL, `lives_in` varchar(100) NOT NULL, `from_originally` varchar(100) NOT NULL, `expires` datetime NOT NULL, `ipaddress` varchar(50) NOT NULL, `browser` varchar(100) NOT NULL DEFAULT 'n/a', `show_email` int(11) NOT NULL DEFAULT '1', `timestamp` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=32 ;
Preview of how the data is stored: http://imgur.com/fdG2n0g
Recap: So how can I instead order the message_groups by when the last message was received instead of when the last group was created?
-
Rather basic. Add ORDER BY column ASC or DESC. You have too many queries. Just use a join. You are also opening and closing php unnecessarily.
More importantly, you hang pictures on a wall. Next time post your code.
<?php $sql_messages = mysqli_query($connect, "SELECT DISTINCT group_id FROM message_group WHERE username = '$username' || recipients = '$username' ORDER BY id DESC;"); $num_messages = mysqli_num_rows($sql_messages); if($num_messages == 0){ ?> <div id="messagegroups"> <div align="center" style="padding: 5px;" id="nomsg">You have no messages at this time.</div> <div id="messagegroupholder"> </div> <?php } else { ?> <div id="messagegroups"> <?php while($row_messages = mysqli_fetch_assoc($sql_messages)){ ?> <?php $snm = mysqli_query($connect, "SELECT * FROM message_group WHERE group_id = '$row_messages[group_id]' ORDER BY id DESC"); $rm = mysqli_fetch_assoc($snm); $nm = mysqli_num_rows($snm); $ur = mysqli_query($connect, "SELECT * FROM users WHERE username = '$rm[recipients]' ORDER BY id DESC;"); $rr = mysqli_fetch_assoc($ur); $um = mysqli_query($connect, "SELECT * FROM messages WHERE group_id = '$row_messages[group_id]' ORDER BY id DESC;"); $rrr = mysqli_fetch_assoc($um); ?> <div id="messagegroupholder"> <div class="qo cj ca js-msgGroup groupclick" id="msg" data-id="<?php echo $rm['group_id']; ?>"> <a class="b"> <div class="qf"> <span class="qj"> <img class="cu qh" src="./img/<?php echo $rr['image']; ?>" style="height: 42px; width: 42px;"> </span> <div class="qg"> <strong><?php echo $rr['username']; ?></strong> and <strong><?php echo $nm - 1 ?> others</strong> <div class="aof"> <?php echo substr($rrr['message'], 0, 60); ?> … </div> </div> </div> </a> </div> </div> <?php } ?> <?php } ?>
-
Rather basic. Add ORDER BY column ASC or DESC
I know that, but I have a sql query inside of another sql query, so how do I order by the 2nd query?
-
Hey there,
I am trying to order my messages by last message received instead of last message created.
(Live Site if you want to try a live preview: https://snaps.im) send a message to: admin
Here is how it is currently:
Here is my mysql table:
I basically need it to order exactly how imessages are stored on an iphone or phone.
-
Can you give me an example line of code for this?
"you would then run a query that selects the data you want in the order that you want it. you would probably want a secondary sort order on the description so that the links are in alphabetical order within any date. you would fetch the data into a multi-dimensional array, using the date as the main array key/index. this will give you a sub-array of data for each date."
Because I am confused if I need a foreach inside the while loop?
Actually, here's what I came up with (didnt include the quotes tho, didnt really understand a good way to do it.)
<p>Quote of the day: <i>Don't watch the clock; do what it does. Keep going.</i></p> <?php $rowdates = mysqli_query($connect, "SELECT DISTINCT datestamp FROM links ORDER BY datestamp DESC"); $dates = array(); while($row = mysqli_fetch_assoc($rowdates)) { $dates[] = $row; } ?> <?php foreach($dates as $value) { ?> <h1><?php echo date('M d Y', strtotime($value['datestamp'])); ?></h1> <strong>Today's Links</strong> <ul> <?php foreach($value as $key => $val) { $sql_links = mysqli_query($connect, "SELECT * FROM links WHERE datestamp = '$val' ORDER BY timestamp DESC, CHAR_LENGTH(description)"); while($row_links = mysqli_fetch_array($sql_links)){ ?> <li><a href="<?php echo $row_links['url']; ?>"><?php echo $row_links['description']; ?></a></li> <?php } } ?> </ul> <hr style="border: 1px dashed grey;"> <?php } ?>
-
you would start by storing the dates using a mysql DATE data type, so that you can do date comparisons (to select the range of dates you are interested in) and so that you can order the data by the date.
you would then run a query that selects the data you want in the order that you want it. you would probably want a secondary sort order on the description so that the links are in alphabetical order within any date. you would fetch the data into a multi-dimensional array, using the date as the main array key/index. this will give you a sub-array of data for each date.
because the quote data is not directly related to the links data, you would query for it separately and fetch it into its own array using the date as the array key/index.
you would then just loop over the main array to access each date, then loop over the sub-array for each date and output the data the way you want. you would use the date value from the main loop to access any quote(s) for that date in the quote data array.
Can you give me an example line of code for this?
"you would then run a query that selects the data you want in the order that you want it. you would probably want a secondary sort order on the description so that the links are in alphabetical order within any date. you would fetch the data into a multi-dimensional array, using the date as the main array key/index. this will give you a sub-array of data for each date."
Because I am confused if I need a foreach inside the while loop?
-
$1000 for lifetime script access to a chatroom? Are you insane? lol
-
Hello fine phpfreak members.
I am having a brain cloud and cannot remember how to get these results out correctly.
Here is my mysql table:
And I need the data to show up like such:
NOTE: I have a table called "quotes" with
[datestamp] -> [Test quote] [Feb-5-2016] -> [test quote 2] [Feb-4-2016] that should be in the mix too.thanks guys.
source site: http://lukeidiot.com
-
Do both code blocks work? If so, are you just wondering how to combine them? If so, have you tried something like:
var suggestCallBack; // global var for autocomplete jsonp var keywordCount = 0; var alphabet = "abcdefghijklmnopqrstuvwxyz0123456789".split(""); $('body').on("click", '#submit', function() { $('#keywords').html(''); var search_input = $("#keyword").val(); var language = $("#edit-domain").val(); callAPI(search_input, language); _.each(alphabet, function(letter) { callAPI(search_input + ' ' + letter); callAPI(letter + ' ' + search_input); }); return false; });
Hey, this mostly works, but for some reason the "letter" stays the same.
Here is a live preview: http://keyworda.com
The problem: (circled in red): http://i.imgur.com/gR46SuE.png
-
I am looping a $.getJSON url with a SEARCHTERM.I want to pro-grammatically also add each letter of the alphabet to the SEARCHTERM like such:
SEARCHTERM
SEARCHTERM
SEARCHTERM
SEARCHTERM a
SEARCHTERM a
SEARCHTERM a
a SEARCHTERM
a SEARCHTERM
a SEARCHTERM
SEARCHTERM b
SEARCHTERM b
SEARCHTERM b
b SEARCHTERM
b SEARCHTERM
b SEARCHTERMHere is the code I am using to loop only the original "SEARCHTERM" without adding the alphabet on each end.Here is the relevant javascript code:
var suggestCallBack; // global var for autocomplete jsonp
var keywordCount = 0;
$('body').on("click", '#submit', function() {
$('#keywords').html('');
var search_input = $("#keyword").val();
var language = $("#edit-domain").val();
callAPI(search_input, language);
return false;
});
function callAPI(s, language) {
$.getJSON("http://suggestqueries.google.com/complete/search?callback=?", {
"hl": language, // Language
//"ds":"yt", // Restrict lookup to youtube
"jsonp": "suggestCallBack", // jsonp callback function name
"q": s, // query term
"client": "youtube" // force youtube style response, i.e. jsonp
});
suggestCallBack = function(data) {
var suggestions = [];
var languageText = $("#edit-domain option:selected").text();
$('#keywordTable').show();
$.each(data[1], function(key, val) {
suggestions.push({
"value": val[0],
});
$('#keywordTable tr:last').after('<tr><td>' + s + '</td><td>' + val[0] + '</td><td>0</td><td>0</td><td>0</td></tr>');
$('#keywordCount').text(++keywordCount);
$('#keywordtext').text(s);
$('#languageholder').text(languageText);
});
}
}code for alphabet (if you need?)
var alphabet = "abcdefghijklmnopqrstuvwxyz0123456789".split("");
_.each(alphabet, function(letter) {
callAPI(search_input + ' ' + letter);
});Summary: I want the relevant code to also add each letter of the alphabet to the beginning and end, while calling callAPI();
-
I used it to make http://youtube-2-mp3.org
-
Looking to pay someone to create a responsive HTML design from this image:
Skype: Lukecode
-
Hello I am trying to output the titles of each of the 10 results provided in the following JSON URL: https://www.googleapis.com/youtube/v3/search?part=snippet&q=test&maxResults=10&key=AIzaSyCoSXBJjRh7ToEJIMH2QF1-UsgK71E_RQ4
function populateRelated(searchTerm){ var search_input = searchTerm; var keyword = encodeURIComponent(search_input); var yt_url2 = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q=' + keyword + '&maxResults=10&key=AIzaSyCoSXBJjRh7ToEJIMH2QF1-UsgK71E_RQ4'; $.getJSON(yt_url2, function(data) { $.each(data, function(i,v){ $('#relatedsongs').append('<a class="dl" href="#" style="font-size: 12px;">' + items[0].id.videoId + '</a><br>'); console.log('worked'); }); }); }
The upper code DOES NOT work. Any idea how I can get it to output the titles for the results only?
Example
Video Title 1Video Title 2
Video Title 3
...
Video Title 10
Thanks.
-
http://infotechnologist.biz/index.jpg
That is 2000ish style. Todays style is flat, minimal, and simple.
www.themeforest.net
-
It would help if you could spell your own sites domain name.
-
Hello guys,
Today I have a simple task that I want to pay you for.
The goal is to incorporate https://hushfile.it/, and have it on my site http://cryptoloader.com
hushfile.it is open source on github located here: https://github.com/hushfile/hushfile
Name your price, as well as payment method. I can pay pretty much any way; Paypal, Bitcoin, Western Union, etc.
EDIT: You don't have to use hushfile, but I want the end result to be able to encrypt/decrypt with client side JS, with the keys stored in the URL. It must be able to handle files over 10MB.
-
Hello,
I have the following httpd (.htaccess) rules that I would like converted to work with lighttpd rules.
RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Thanks in advance!
-
Did you call the function?
$proxy = getProxy(); echo $proxy;
Yes sir;
How to simplify this JavaScript into something useable?
in Javascript Help
Posted · Edited by requinix
removing site because I'm peeved
Here is what I managed to come up with: