Overflow

html-webpack-plugin with webpack-strip-blocks – Stack Overflow


I want to strip out a section of code before html webpack plugin loads the file.

In webpack.config.js rules section, I have

[ ...otherrules,
  {
    test: /.html$/,
    enforce: 'pre',
    use: [{
      loader: 'webpack-strip-blocks',
      options: {
        blocks: blocks,
        start: '<!--',
        end: '-->'
      }
    }]
  },
  ...evenMoreOtherRules
]

and in the plugins section

plugins: [
      new HtmlWebpackPlugin({
        template: path.resolve(__dirname, './app/index.html'),
        filename: 'index.html',
        inject: 'body'
      }),
      ...otherPlugins
]

When I try running it I am getting

ERROR in ./~/html-webpack-plugin/lib/loader.js!./app/index.html
Module parse failed: /Users/neolivz/Work/neolivz/node_modules/html-webpack-plugin/lib/loader.js!/Users/neolivz/Work/neolivz/node_modules/webpack-strip-blocks/index.js??ref--7-0!/Users/neolivz/Work/neolivz/app/index.html Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <!DOCTYPE html>
| <html>
| <head>



لینک منبع

HMAC-SHA256 in Rust – Stack Overflow


I’m trying to make a function in Rust that will return a HMAC-SHA256 digest. I’ve been working from the description at Wikipedia and RFC 2104.

I’ve been struggling with returning the correct HMAC. I’m using ring for the SHA256 digests but no matter what I try, I can’t seem to get the right result. I suspect it might have something to do with .as_ref().to_vec() conversions. Even if that’s true, I don’t know how to continue from that. Not everything from the RFC 2104 is implemented in the following code, but it highlights my issue. All feedback is appreciated, thanks!

extern crate ring;
use ring::{digest, test};

pub fn hmac(k: Vec<u8>, mut m: Vec<u8>) -> Vec<u8> {
    // Initialize ipad and opad as byte vectors with SHA256 blocksize
    let ipad = vec![0x5C; 64];
    let opad = vec![0x36; 64];
    // iround and oround are used to seperate the two steps with XORing
    let mut iround = vec![];
    let mut oround = vec![];

    for count in 0..k.len() {
        iround.push(k[count] ^ ipad[count]);
        oround.push(k[count] ^ opad[count]);
    }

    iround.append(&mut m); // m is emptied here
    iround = (digest::digest(&digest::SHA256, &iround).as_ref()).to_vec();
    oround.append(&mut iround); // iround is emptied here
    oround = (digest::digest(&digest::SHA256, &oround).as_ref()).to_vec();
    let hashed_mac = oround.to_vec();

    return hashed_mac;
}

#[test]
fn test_hmac_digest() {
    let k = vec![0x61; 64];
    let m = vec![0x62; 64];
    let actual = hmac(k, m);
    // Expected value taken from: https://www.freeformatter.com/hmac-generator.html#ad-output
    let expected = test::from_hex("f6cbb37b326d36f2f27d294ac3bb46a6aac29c1c9936b985576041bfb338ae70").unwrap();
    assert_eq!(actual, expected);
}

These are the digests:

    Actual = [139, 141, 144, 52, 11, 3, 48, 112, 117, 7, 56, 151, 163, 65, 152, 195, 163, 164, 26, 250, 178, 100, 187, 230, 89, 61,
۱۹۱, ۱۶۴, ۱۴۶, ۲۲۸, ۱۸۰, ۶۲]

Expected = [246, 203, 179, 123, 50, 109, 54, 242, 242, 125, 41, 74, 195, 187, 70, 166, 170, 194, 156, 28, 153, 54, 185, 133, 87,
 ۹۶, ۶۵, ۱۹۱, ۱۷۹, ۵۶, ۱۷۴, ۱۱۲]



لینک منبع

javascript – Inline Disabling – Stack Overflow


I am disabling a button inline using Django conditions

<button 
     {% if order.return_available == True %} disabled="disabled" {% endif%} 
     class="class1 class2 
     {% if order.return_available == True %} disabled {% endif %}">

Problem is that when I play around with the Chrome Dev Tools and manually change those inline disables, it removes the disable formatting and triggers the POST for the form and actually updates the database. Will this be the same for when deployed and for the end user?



لینک منبع

serveral questions for visual-studio-code – Stack Overflow


Try use vsc to work instead of sourceinsight…got many problems…

Working on C lang mostly. Any suggestions are appreciated..

۱, How to modify MACRO color?

۲, How to modify variable color? the following settings doesn’t work. Vars are always white.

    "editor.tokenColorCustomizations": {
    "variables": "#2b3590",
    "textMateRules": [
    {
        "name": "Function argument",
        "scope": "variable.parameter",
        "settings": {
            "fontStyle": "",
            "foreground": "#6089B4"
        }
    },
    {
        "name": "Function Call Variable",
        "scope": "variable.other.property",
        "settings": {
            "fontStyle": "",
            "foreground": "#9872A2"
        }
    },
    {
        "name": "Class Variable",
        "scope": "variable.other, variable.js, punctuation.separator.variable",
        "settings": {
            "fontStyle": "",
            "foreground": "#6089B4"
        }
    },
    {
        "name": "Normal Variable",
        "scope": "variable.other.php, variable.other.normal",
        "settings": {
            "fontStyle": "",
            "foreground": "#6089B4"
        }
    }
    ]
},

۳, I use llvm clang as an extension. But I got some weird error squiggles or error-parameter notice or include error notice:
enter image description here

enter image description here

enter image description here

Extensions I used is:

enter image description here



لینک منبع

firebase – Firestore Query/Performance – Stack Overflow


I am new to firestore, I am.confused with the pricing/shallow structure. Would like to know the better way of querying a set of data I have.

I have the data structure as follow:

  • (a) collection – main collection

  • (b) document – multiple documents in the range of 100’s

  • (c) collection – sub collection

  • (d) document – multiple documents in the range of 35 k to 45k

My query will be usually getting data from (d) collection using ‘where’ clause.

  • would it be better to remove the subcollections and have all it in the (b) documents and keep an extra ref parameter for querying. Keeping like it will increase the (b) document into 100k’s of values.

  • does the pricing vary if I change to that data structure,which would be better for pricing and performance.

    • does the pricing(read) depend on the whole set of 100k’s or only on the 20 or 30 values returned after the where clause query.



لینک منبع

XML/JSON vs. SQlite (Android) – Stack Overflow


I am developing an Android app for recording measurements than will run on a propriatery device. The device is linked to a sensor array, so each measurement set contains about 10 items. Each user specifies which project and environment the measurement is part of, e.g. User A – Customer X – Place Y – Project Z – Measurements [] – Sensor Data []. At worst, there will be 5 Users, 10 plants each, 5 Machines with with up to 50 measurement sets (assuming the users don’t back-up their data on a PC later). In total, 125.000 tuples will have to be stored, for more typical application I am expecting about 2000. The operations performed on that data are quite simple – “display NOK results”, “display results of project Z”, “display latest results”.

Is SQlite the way to go or is there any reason alternatives should be considered? I am unsure because the data structure is a tree rather than inherently relational.



لینک منبع

WPF: gauge value converter – Stack Overflow


So i have simple Gauge class with static int property that implement Propertychanged:

TotalPacketsSent

This property is raising all the time and i want to wrote simple converter and send this converter this property value and return some value base on this property:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ((double)MyClass.TotalPacketsSent / MyClass.TotalPacketsInList) * 100;;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Under Window.Resources i have this:

<Convertors:GaugeValueConverter x:Key="GaugeValueConverter"/>

And this is my Gause:

<Controllers:Gauge x:Name="gauge"
                   Value="{Binding Path=(my:MyClass.TotalPacketsSent), Converter={StaticResource GaugeValueConverter}}"
                   Minimum="0"
                   Maximum="100"/>

So my issue is that my converter not working at all, i mean that i cannot see that this even executed.
Any ideas why ?



لینک منبع