> const today = new Date(2016, 7, 7)
undefined
> const tomorrow = new Date(2016, 7, 8)
undefined
> tomorrow >= today
true
> today <= tomorrow
true
> today == tomorrow
false
const allowed = {
'1': true,
'2': true,
'3': true,
'4': true,
'5': true,
'6': true,
'7': true,
'8': true,
'9': true,
'0': true,
'ArrowLeft': true,
'ArrowDown': true,
'ArrowRight': true,
'ArrowUp': true,
'Backspace': true,
'.': true,
}
const isValidInput = allowed[key]
def __getCurlOutput (self, url, **kwargs):
curlcmd = "curl {0}".format(url)
for key, value in kwargs.items():
key = key.lower()
if key == "origin":
curlcmd += " -H 'Origin: {0}'".format(value)
elif key == "contenttype":
curlcmd += " -H 'Content-Type: {0}'".format(value)
elif key == "referer":
curlcmd += " -H 'Referer: {0}'".format(value)
elif key == "cookie":
curlcmd += " -H 'Cookie: {0}'".format(value)
elif key == "data":
curlcmd += " --data '{0}'".format(value)
elif key == "verbose":
if value == True:
curlcmd += " --verbose"
else:
curlcmd += " --silent"
elif key == "output":
curlcmd += " --output {0}".format(value)
else:
print "Unsupported key: {0}".format(key)
curlcmd += " 2>&1"
print curlcmd
curlout = subprocess.check_output(curlcmd,shell=True)
return curlout
<style type="text/css">
<?php echo file_get_contents(
\realpath(ROOT_PATH . '/public/').$this->assetPath('css/styles.css', true)
); ?>
</style>
Including style file (about 100kb) directly to HTML page. Thanks for developer, it's in
.def even?(number)
if number > 0
result = number
else
result = -number
end
while result > 2 or result == 2
result = result - 2
end
if result == 0
true
else
false
end
end
Best solution to find out if a number is even.
const Discord = require("discord.js");
const bot = new Discord.Client();
const TOKEN = "NOPE"
var color = require('chalk');
var fs = require('fs');
bot.on("ready", function(message) {
console.log(color.green("Online"))
})
bot.on("message", function(message){
console.log("Channel:" + color.blue(message.channel) + " " + "Author:" + color.blue(message.author) + " " + "Message:" + color.blue(message.content))
if (message.content.includes("uranium") || message.content == "Uranium" || message.content == "uranium" || message.content.includes("uranium")) {
console.log(color.black.yellow("Message Flagged As Suspicous"))
console.log(color.black.yellow("Contains: Uranium"))
console.log(color.black.bgYellow("Message:" + message.content))
console.log(color.black.bgYellow("Message Id:" + message.id))
console.log(color.black.bgYellow("Author Id:" + message.author.id))
console.log(color.black.bgYellow("Channel Id:" + message.channel.id))
console.log(color.yellow("Severity:" + "1"))
var alertsev1 = `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}`
fs.writeFile('alerts.txt', `${alertsev2}`)
}
if (message.content.includes("raid") || message.content.includes("Raid")) {
console.log(color.black.red("Message Flagged As Suspicous"))
console.log(color.black.red("Contains: Raid"))
console.log(color.black.bgRed("Message:" + message.content))
console.log(color.black.bgRed("Message Id:" + message.id))
console.log(color.black.bgRed("Author Id:" + message.author.id))
console.log(color.black.bgRed("Channel Id:" + message.channel.id))
console.log(color.black.red("Severity:" + "2"))
var alertsev2 = `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}`
fs.writeFile('alerts.txt', `${alertsev2}`)
}
if (message.content.includes("raid") && message.content.includes("uranium") || message.content.includes("raid") && message.content.includes("Uranium") || message.content.includes("raid") && message.content.includes("uranium") || message.content.includes("Raid") && message.content.includes("uranium") || message.content.includes("Raid")) {
console.log(color.black.red("Message Flagged As Possible Raid Initiation"))
console.log(color.black.red("Contains: Raid, Uranium"))
console.log(color.black.bgRed("Message:" + message.content))
console.log(color.black.bgRed("Message Id:" + message.id))
console.log(color.black.bgRed("Author Id:" + message.author.id))
console.log(color.black.bgRed("Channel Id:" + message.channel.id))
console.log(color.black.red("Severity:" + "3"))
var alertsev3 = `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}`
fs.writeFile('alerts.txt', `${alertsev3}`)
}
})
bot.login(TOKEN)
I'm making a discord message logger but I want to output message.content message.author message.id message.channel.id into one text file everytime a message is sent in the following format: Message ID:(Id here) Message Author: (Author ID here) Channel ID: (Channel ID here) Message: (message here) ive tried with the following code but it printed undefined out into the text document
export const LandingReducer=createSlice({
name:'MAIN_SLICE',
initialState:initialStates,
reducers: {
changeStateValue:(state,action) => {
state[action.payload.name] = action.payload.value
const check = action.payload.name.includes('.')
if (!check) {
state[action.payload.name] = action.payload.value
}else{
const groups=action.payload.name.split('.')
console.log(groups);
if(groups.length===2){
state[groups[0]][groups[1]]=action.payload.value;
}else if(groups.length===3){
state[groups[0]][groups[1]][groups[2]]=action.payload.value;
}else if(groups.length===4){
state[groups[0]][groups[1]][groups[2]][groups[3]]=action.payload.value;
}
}
}
}
});
if (!String.prototype.replaceLast) {
String.prototype.replaceLast = function(find, replace) {
String.prototype.replaceLast = function (what, replacement) {
var pcs = this.split(what);
var lastPc = pcs.pop();
return pcs.join(what) + replacement + lastPc;
};
};
}
Prototypes are super buggy anyway, I should rewrite that as a pure function.
public static String arrayToString(List list) {
if (list == null) {
throw new IllegalArgumentException("list is null");
}
return list.toString()
.replace("[", "") //remove the right bracket
.replace("]", "") //remove the left bracket
.trim();
}
string sum_numbers(string a, string b) {
char ca, cb, ci, out, co = '0';
string result = "";
while (a.size() > 0 || b.size() > 0 || co != '0') {
ci = co; ca = '0'; cb = '0';
if (a.size() > 0) {ca = a.back(); a.pop_back();}
if (b.size() > 0) {cb = b.back(); b.pop_back();}
result = ((((ca != cb) ? '1' : '0') != ci) ? '1' : '0') + result;
co = ((((ca == '1' && cb == '1') ? '1' : '0') == '1' ||
((((ca != cb) ? '1' : '0') == '1' && ci == '1') ? '1' : '0') == '1') ? '1' : '0');
}
return result;
}
Scary stuff
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>
constexpr int N = 10;
int main() {
std::vector<int> even;
std::vector<int> odd;
even.resize(N);
// Fill up the 'even' vector with integers starting from from 1 through 'N'
std::iota(even.begin(), even.end(), 1);
// Segregate the odd and even integers from each other
for (auto it = even.begin(); it != even.end(); ++it)
if (*it % 2 != 0) {
// If the number is odd, put it in the 'odd' vector
odd.push_back(*it);
// Remove the number from the even vector
even.erase(it);
}
// Print the result
std::cout << "Even numbers: ";
std::copy(even.begin(), even.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << "\nOdd numbers: ";
std::copy(odd.begin(), odd.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << '\n';
}
Seems fine to me... C++ couldn't possibly be THAT evil to introduce another nuanced and verbose complexity in there, right?
fn add_unsafe(a: i32, b: i32) -> i32 {
a + b
}
fn add_safer(a: i32, b: i32) -> std::io::Result<i32> {
Ok(add_unsafe(a, b))
}
fn add_option(a: i32, b:i32) -> Option<std::io::Result<i32>> {
Some(add_safer(a, b))
}
fn main() {
println!("{:?}", add_option("4".parse::<i32>().unwrap(), "5".parse::<i32>().unwrap()).unwrap().unwrap());
}
it unwraps
string AllPDF = "";
int CountPDF = 0;
AllPDF = txtInput.Text;
string[] AllPDF2 = AllPDF.Split(';');
List<string> PDF = new List<string>();
PDF.AddRange(AllPDF2);
while (PDF.Count != CountPDF)
{
File.Delete(AllPDF2[0 + CountPDF] + ".pdf");
CountPDF++;
}
I believe, there are so many easier ways to do that
//JSONObject input;
String givenName = input.get("propName") != null ? (String)input.get("propName") : null;
WHAT DA FUCK ASSHOLES
int var = 0;
int* ptr = &var;
ptr[0] = 5;
std::cout << ptr[0];