> 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.
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;
}
}
}
}
});
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();
}
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
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
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
// this.collectPairs() returns data from the UI form
// this.alert.alarmReasons contains empty array or alarmReason-Category pair objects
let newAlarmReasonsToAdd = []
this.collectPairs().forEach(categoryAndAlarmReasonPair => {
!!!this.searchAmidExisting(categoryAndAlarmReasonPair, this.alert.alarmReasons) ? newAlarmReasonsToAdd.push(categoryAndAlarmReasonPair) : null
})
searchAmidExisting(alarmReasonToAdd, existingAlarmReasons){
let res = existingAlarmReasons.find(existing => {
if(alarmReasonToAdd.categoryDictEntryKey === existing.category && alarmReasonToAdd.reasonDictEntryKey === existing.reason){
return true
} else return false
})
return res
}
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.
#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?
int i = 0;
while (conn == null && i < 116) {
try {
Thread.sleep(i < 30 ? 2000 : (i < 40 ? 6000 : (i < 56 ? 30000 : 60000)));
} catch (Exception e) {
e.printStackTrace();
}
try {
conn = Server.getConnection();
} catch (Exception e) {
//e.printStackTrace();
}
i++;
if ((i < 41 && (i % 5) == 0)
|| (i > 40 && i < 45)
|| (i > 44 && i < 56 && (i % 2) == 0)
|| (i > 55 && ((i - 56) % 3) == 0))
System.out.print('.');
}
/*
* _____________________________________________________
* ___________↓___↓____________________________________________ |
* _↓_________↓|___|________________________________________ | |
* ______↓|_________||___|↓___________________________________ | | |
* _____↓__↓__||_________||___||_______________________________ | | | |
* _↓__↓_|__|__||_________||___||___________________________ | | | | |
* _________↓|__|_|__|↓_||_________||___||_______________________ | | | | | |
* ↓ ↓ || | | || || || || | | | | | | | */
opcId = child.replace(/([.])?(?:((.+)=(.+))|(([a-zA-Z]+)(\d*)))/g, function (match, m1, m2, m3, m4, m5, m6, m7) {