void MagicUnit::getSomeVoltage(std::uint64_t w_data, double &val)
{
std::uint64_t r_data = 0;
hwRead((int)Address::Voltage, 3, w_data, 2, &r_data);
val = r_data;
val /= 16; // shit right 4 bits
val *= 0.004;
val -= 8.192;
}
<Image source={ this.props.pickupOrDropoff == "pickup"
? i.pickup
? iconBlue
: iconWhite
: i.dropoff
? iconBlue
: iconWhite} style={{
height:this.props.pickupOrDropoff == "pickup"
? i.pickup
? 30
: i.sign === 'D' ? 30 : 35
: i.dropoff
? 30
: i.sign === 'D' ? 30 : 35,
marginRight:10 ,
width: this.props.pickupOrDropoff == "pickup"
? i.pickup
? 40
: 40
: i.dropoff
? 40
: 40
,resizeMode:'contain'}}/>
I love when the code is neat...
.black {
color: #000;
}
.not-black {
color: #999;
}
return [word for word in words if any(all(ch in row for ch in word.lower()) for row in rows)]
Filtering words that can be typed using only one row of the keyboard.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
void run_func(char *map[], char *fnt , char *km , float *x , float *y , int line , int row , int lift );
char *long_met[3][8] = {{"mile","0.621371" , "yard","1093.61" , "fut","3280.84" , "duim","39370.1" } ,
{ "mile" ,"1.60934" , "yard","0.0009144" , "fut","0.0003048" , "duim","0.0000254"},
{"kilometer","1" , "meter","1000" , "stmeter","100000" , "mmeter","1000000" } };
char *amount[3][4] = { { "gallon" , "0.264172" , "quarta" , "1.05669" } ,
{"gallon" , " 3.78541" , "quarta" , "0.946353" },
{"litr" , "1" , "mililitr" , "1000" }};
char *mass[3][8] = { {"eng.tonna","0.984207" , "amer.tonna","1.10231" , "stone","157.473" , "funt","2204.62" } ,
{ "eng.tonna" , "1.01605" , "amer.tonna", "0.907185" , "stone","0.00635029" , "funt","0.000453592"},
{"tonna","1" , "kilogram" , "1000" , "miligram","100000" , "microgram","1000000" }};
char **cp;
char *buf_data;
char *fnt_sys;
char *mtr_sys;
char *word[100];
while(1){
int bg = 0,convert_ch = 3,y = 0, d = 0, numb = 0;
float mn =0 , xm = 0 ;
printf("%s", "enter data for converter: ");
fgets( (char *) word, 99 ,stdin);
buf_data = strtok((char *) word, " ");
if( ! strcmp(buf_data, "funt.sys" ) ){
convert_ch = 0;
}
else if( ! strcmp(buf_data, "metric.sys" ) ){
convert_ch = 1;
}
for( bg = 0 ; buf_data != NULL; buf_data = strtok(NULL, " ") , bg++ ) {
switch(bg){
case 1:
if( !strcmp("long_met" , buf_data ) ){
y = sizeof(*long_met) / sizeof(long_met[0][0]);
d = sizeof(long_met) / sizeof(long_met[0][0]);
cp = &long_met[convert_ch][0] ;
}
else if(!strcmp("amount" , buf_data ) ){
y = sizeof(*amount) / sizeof(amount [0][0]);
d = sizeof(amount) / sizeof(amount[0][0]);
cp = &amount[convert_ch][0] ;
}
else if(!strcmp("mass" , buf_data ) ){
y = sizeof(*mass ) / sizeof(mass[0][0]);
d = sizeof(mass ) / sizeof(mass[0][0]);
cp = &mass[convert_ch][0] ;
}
break;
case 2:
fnt_sys = buf_data;
break;
case 3:
mtr_sys = buf_data;
break;
case 4:
numb = atoi(buf_data);
break;
}
}
if( !y || !d || !cp || convert_ch == 3 || !numb ){
puts("error");
}
else{
run_func( cp, fnt_sys , mtr_sys , &mn , &xm , y , d , convert_ch );
if( !mn || !xm ){
puts("error");
} else{
printf("%f\n" , !convert_ch ? (mn / xm ) * numb : ( mn * xm ) * numb );
}
}
}
return 0;
}
void run_func(char *map[], char *fnt , char *km , float *x , float *y , int line , int row , int lift ){
int m ;
if( ( lift ) ){
row -= line;
}
for( m = 0 ; m <= line ; m++){
if(!strcmp(fnt,map[m])){
*x = atof(map[m + 1] ) ;
break;
}
}
for( m = (row - line) ; m <= row - 1 ; m++){
if( !strcmp( km , map[m] ) ){
*y = atof(map[m + 1 ] );
break;
}
}
}
if (model.env.Trim().ToUpper() == "Release")
{
retVal = false;
if (!string.IsNullOrEmpty(model.Server_Core))
{
// Perform a trim in case user specified just whitespace...
string tmpStr = model.Server_Core.Trim();
if (!string.IsNullOrEmpty(tmpStr))
{
retVal = true;
}
}
}
function uberURLREPLACER(dtTEXTVALUE,boolVALUE){
// If statement? what's that??
// Naming conventions? Of course not!
// true/false keywords? I never heard it.
boolVALUE != !1 && dtTEXTVALUE.indexOf('http://') != -1 && (dtTEXTVALUE = dtTEXTVALUE.replace('http://','')) && dtTEXTVALUE.indexOf('.aspx') == -1 && (dtTEXTVALUE += '.aspx');
return dtTEXTVALUE;
}
Here's the weirdest way to create if statement with terrible naming conventions. Its based on real events and production code.
function urlREPLACER(dtTEXTVALUE){
dtTEXTVALUE.indexOf('http://') != -1 && (dtTEXTVALUE = dtTEXTVALUE.replace('http://','')) && dtTEXTVALUE.indexOf('.aspx') == -1 && (dtTEXTVALUE += '.aspx');
return dtTEXTVALUE;
}
string date = user.RegistrationDate.ToShortDateString().ToString();
CREATE OR REPLACE FUNCTION melodious.query_flags(user_name varchar(32), chan_name varchar(32), igroup_name varchar(32), iflag_name varchar(32), flagcheck bool)
RETURNS TABLE (
group_holders jsonb [],
flag_id int4,
flag_name varchar(32),
flag jsonb
)
LANGUAGE plpgsql
AS $$
DECLARE
uid int4 := NULL;
cid int4 := NULL;
gid int4 := NULL;
BEGIN
IF user_name <> '' THEN
SELECT id INTO uid FROM melodious.accounts WHERE username=user_name;
IF uid IS NULL THEN
RAISE EXCEPTION 'no such user';
END IF;
END IF;
IF chan_name <> '' THEN
SELECT id INTO cid FROM melodious.channels WHERE name=chan_name;
IF cid IS NULL THEN
RAISE EXCEPTION 'no such channel';
END IF;
END IF;
IF igroup_name <> '' THEN
SELECT id INTO gid FROM melodious.groups WHERE name=igroup_name;
IF gid IS NULL THEN
RAISE EXCEPTION 'go such group';
END IF;
END IF;
IF igroup_name = '' THEN
IF iflag_name = '' THEN
IF user_name = '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (NOT flagcheck) OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (gh.user_id = uid AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (NOT flagcheck AND gh.user_id = uid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
GROUP BY gf.id, gf.name;
ELSIF user_name = '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (NOT flagcheck AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
GROUP BY gf.id, gf.name;
END IF;
ELSE
IF user_name = '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (gf.name = iflag_name)
AND (
(NOT flagcheck)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gf.name = iflag_name
AND (
(gh.user_id = uid AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gf.name = iflag_name
AND (
(NOT flagcheck AND gh.user_id = uid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name = '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB((SELECT name FROM melodious.groups WHERE id=gh.group_id LIMIT 1)))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gf.name = iflag_name
AND (
(NOT flagcheck AND gh.channel_id = cid)
OR (flagcheck AND gh.channel_id = cid AND gh.user_id IS NULL)
OR (flagcheck AND gh.channel_id IS NULL AND gh.user_id IS NULL)
)
GROUP BY gf.id, gf.name;
END IF;
END IF;
ELSE
IF iflag_name = '' THEN
IF user_name = '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gh.group_id = gid
AND (
(NOT flagcheck)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gh.group_id = gid
AND (
(gh.channel_id = cid AND gh.user_id = uid)
OR (flagcheck AND gh.channel_id = cid AND gh.user_id IS NULL)
OR (flagcheck AND gh.channel_id IS NULL AND gh.user_id = uid)
OR (flagcheck AND gh.channel_id IS NULL AND gh.user_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gh.group_id = gid
AND (
(NOT flagcheck AND gh.user_id = uid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name = '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE gh.group_id = gid
AND (
(NOT flagcheck AND gh.channel_id = cid)
OR (flagcheck AND gh.channel_id = cid AND gh.user_id IS NULL)
OR (flagcheck AND gh.channel_id IS NULL AND gh.user_id IS NULL)
)
GROUP BY gf.id, gf.name;
END IF;
ELSE
IF user_name = '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
INNER JOIN melodious.groups g
ON g.id = gh.group_id
WHERE (gf.name = iflag_name AND gh.group_id = gid)
AND (
(NOT flagcheck)
OR (flagcheck AND gh.channel_id IS NULL AND gh.user_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (gf.name = iflag_name AND gh.group_id = gid)
AND (
(gh.user_id = uid AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id = cid)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name <> '' AND chan_name = '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (gh.group_id = gid AND gf.name = iflag_name)
AND (
(NOT flagcheck AND gh.user_id = uid)
OR (flagcheck AND gh.user_id = uid AND gh.channel_id IS NULL)
OR (flagcheck AND gh.user_id IS NULL AND gh.channel_id IS NULL)
)
GROUP BY gf.id, gf.name;
ELSIF user_name = '' AND chan_name <> '' THEN
RETURN QUERY SELECT
ARRAY_AGG(JSONB_SET(ROW_TO_JSON(gh)::JSONB, '{group_name}'::TEXT[], TO_JSONB(igroup_name))) AS group_holders,
gf.id flag_id,
gf.name flag_name,
gf.flag flag
FROM melodious.group_holders gh
INNER JOIN melodious.group_flags gf
ON gh.group_id = gf.group_id
WHERE (gf.name = iflag_name AND gh.group_id = gid)
AND (
(NOT flagcheck AND gh.channel_id = cid)
OR (flagcheck AND gh.channel_id = cid AND gh.user_id IS NULL)
OR (flagcheck AND gh.channel_id IS NULL AND gh.user_id IS NULL)
)
GROUP BY gf.id, gf.name;
END IF;
END IF;
END IF;
END;
$$;
public class NullableFloatToNullableDoubleConverter : ITypeConverter<float?, double?>
{
public double? Convert(float? source, double? destination, ResolutionContext context)
{
if (source == null)
{
return null;
}
var floatAsString = source.Value.ToString(CultureInfo.InvariantCulture);
return double.Parse(floatAsString);
}
}
if (responseCode / 100 == 2) {//success
return handleSuccess();
} else if (responseCode == 401) {
return handleNotAuthorized();
} else {
// something else
}
doit({txs, [Tx]}) ->
X = tx_pool_feeder:absorb(Tx),
Y = case X of
ok -> hash:doit(testnet_sign:data(Tx));
_ -> <<"error">>
end,
{ok, Y};
In my opinion api response should be as confusing as possible. This method is used for sending tx into Amoveo blockchain. It returns ["ok",
date('Y-m-d').'T'.date("H:i:s", strtotime("- 1 hour")).'Z'
Back to the future
class FileReader extends EventTarget(...READER_EVENTS) {
// [...]
readAsArrayBuffer() {
throw new Error('FileReader.readAsArrayBuffer is not implemented');
}
}
React Native's way of saying they don't support FileReader.readAsArrayBuffer()