Saturday, 15 August 2015

javascript - dynamic grid as custom directive -


I am relatively new to Kangaroo and stuck on custom instructions. I am trying to create a dynamic grid as a custom directive. I have already had to work as part of this:

There are some scenarios where I need to set the attributes on some elements of the grid. This part has me Stumped I am planning to include attributes in the form of an array inside the object and then putting it in the html tag of the affiliate entry. This section is shown here:

If you look at the "entries" array in the controller, then I have now changed it to include an "attributes" array In which the property properties and properties should be applied to these related columns then the corresponding columns.

For example

  (first entry of the array) col1: {text: 'Obj1.col1', attributes: [{atri: 'ng-class', attriv : 'Probaul =='? "SomeClass": "someOtherClass" '}, {attr:' id ', attrVal:' {{propName}} {{$ index}} '}]}, ... Sorting for a brief  

This array entry should be translated into:

  & lt; Td ng-class = "propVal ==" 'some class': 'someOtherClass' "id =" col11 "& gt; Obj1.col1 & lt; / TD & gt;  

I have read some articles about executing orders for compilation, controller, pre-link and post-link functions and play with different commands and try to compile themselves. , But all this has failed, probably because I do not understand the depth of how it all are relation together. If someone can help me in the right direction or point in the right direction, if I am going on the wrong path, then I appreciate it.

OK, in the end I thought how using an embedded custom instructions inside an original custom command Grid should be generated in a grid dynamically.

Here is a show that shows how I did this:

I have HTML templates defined:

  & lt; Div ng-grid ng-collection = "entries" ng -collection- headings = "headings" ng-button-click = "the action (INP)" & gt; & Lt; Div ng-checkbox-column & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

and then as ng-grid directive :

 . (NgCollectionHeadings: "=", ngCollection: "=", ngButtonClick: "& amp;"}, Template: function (element, etters); directive ("ngGrid", function () {return: restricted: "A", scope: {Var children = element.html (); Kids = Children (.trim) Copy (/ div / g, "td"); var htmlText = "& lt; input type = 'button' ng-click = 'button clicked ( ) 'Value' = Grid Directive '/> & lt; {{Heading}} & lt; / th & gt; & lt; / tr & gt; & lt; Table Category =' Table Table-boundary '&' Gt; & lt; thead & gt; & lt; tr & gt; & lt; th ng-repeat = 'heading ng cloling heading'; / tad & Gt; TDA & gt; & lt; tr id = 'item {{$ index}}' ng-repeat = 'item in nigulation' & gt; "+ children +" & lt; / tr & gt; & lt; / Tag & gt; & lt; / table & gt; "; HTMLText;} Return, Controller: Function ($ area, $ element) {$ scope.buttonClicked = function (inp) {if (typeof inp! = 'Undefined' ); Inp = inp + ", via grid instruction."; Else inp = "From the grid instruction."; $ Scope.ngButtonClick ({inp: inp});}}}};})  
and finally ng-checkbox-column director :

  .directive ("ngCheckboxColumn", function () {return {restricted: "A" , Template: Function (L Ermines, attributes) {var htmlText = "& lt; Td> & Lt; Label & gt; Input type = 'checkbox' ng-model = 'item.checked' ng-click = 'TempButtonClicked ()' /> From the checkbox directive. & Lt; / Labels & gt; & Lt; / Td> "HTML Text; Return; Controller: Function ($ Scope, $ element) {$ scope.tempButtonClicked = function} {Var val =" From checkbox directive "; $ scope.buttonClicked (val);}}}}}}  

My data collection is very straight forward:

  $ scope.headings = {head1: 'title1', head 2: 'Heading 2', Head 3: 'Heading 3'}; $ Scope.entries = [{col1: 'Obj1.col1', col2: 'Obj1.col2', col3: 'Obj1.col3', checked : Incorrect}, {col1: 'Obj2.col1', col2: 'Obj2. Col2', col3: 'Obj2.col3', checked: incorrect}, {col1: 'Obj3.col1', col2: 'Obj3. Col2 ', col3:' Obj3.col3 ', checked: incorrect}, {col1:' Obj4.col1 ', col2:' Obj4.col2 ', col3:' Obj4.col3 ', f OK: It is still not completely completed, but you should get the original idea. 


php - Calculate and Convert IPv6 Address based on CIDR Prefix -


I have an IPv6 address with a CIDR prefix. Ex: 2001: 0: 3238: DFE1: 0063 :: efef / 32

I would like to write a function such that the IPv6 address matches the number of bits CIDR The prefix is ​​provided, this means if a prefix of 32 is provided, then 32 bits in the IP address should start from left and the remaining should be zero. In the above example, the desired output should be:

  2001: 0000: 0000: 0000: 0000: 0000: 0000: 0000/32  

I 2001 :: / 32

The CIDR prefix can range from 0-128.

It is based on this post so far what is mine, but I'm not sure it is giving the desired output. Can anyone see it and help? Am I thinking about the representation of CIDR directly?

  public function getCIDR metadata ($ ipAddress) {// address and prefix length divided into list ($ firstaddrstr, $ prefixlen) = explosion ('/', $ IPADDRESS); // Parse the address in a binary string $ firstaddrbin = inet_pton ($ firstaddrstr); // To convert binary string into hexadecimal characters with #expack (), the string is used with bin2hex () # unpack () for packing with perpendiculars ($) below $ firstaddrhex = reset (unpack (' H * ', $ firstaddrbin)); // Overwrite the first address string to ensure that the notation is optimal $ firstaddrstr = inet_ntop ($ firstaddrbin); $ CidrMatchedString = $ firstaddrstr '/'. $ Prefixlen; Countercurrent $ cidrMatchedString; }  

here:

  function getCIDRMatchedIP ($ IP) {if (strokes ($ IP, "::")! == incorrect) {$ parts = explosion (":", $ IP); $ Cnt = 0; // The number of numbers in that number ($ i = 0; $ i & lt; count ($ parts); $ i ++) {if (numeric_emeric ("0x". $ Parts [$ i]) $ Cnt ++; } // How many 0000 blocks is required $ required = 8 - $ cnt; $ Ip = str_replace ("::", str_repeat (": 0000", $ required), $ ip); } List ($ ip, $ prefix_len) = explosion ('/', $ ip); $ Parts = explosion (":", $ ip); // This start bit mask is $ bstring = str_repeat ("1", $ prefix_len) Str_repeat ("0", 128 - $ prefix_len); $ Mins = str_split ($ bstring, 16); $ Start = array (); For ($ i = 0; $ i & lt; 8; $ i ++) {$ min = base_convert ($ min [$ i], 2, 16); $ Start [] = sprintf ("% 04s", dickhex (hexdack ($ parts [$ i]) and hexack ($ min)); } $ Start = implode (':', $ start); Return $ start '/' $ prefix_len; }  

and you call the function getCIDRMatchedIP :

  echo getCIDRMatchedIP ('2001: 0: 3238: DFE1: 0063 :: FEFB / 32 ');  

language agnostic - Is floating point math broken? -


  0.1 + 0.2 == 0.3 - & gt; झूठा  
  0.1 + 0.2 - & gt; 0.30000000000000004  

ऐसा क्यों होता है?

बाइनरी गणित की तरह है इस। अधिकांश प्रोग्रामिंग भाषाओं में, यह पर आधारित है। जावास्क्रिप्ट 64-बिट फ्लोटिंग प्वाइंट प्रस्तुति का उपयोग करता है, जो जावा के डबल के समान है समस्या की जड़ यह है कि संख्याएं इस स्वरूप में एक पूर्ण संख्या के रूप में दो की शक्ति का प्रतिनिधित्व करती हैं; तर्कसंगत संख्याएं (जैसे 0.1 , जो कि 1/10 है) जिसका दोरार्य दो की शक्ति नहीं है, वह बिल्कुल प्रतिनिधित्व नहीं किया जा सकता।

मानक binary64 स्वरूप में, प्रतिनिधित्व ठीक तरह से लिखा जा सकता है

  • 0.1000000000000000055511151231257827021181583404541015625 दशमलव में, या
  • 0x1.999999999999ap-4 इन।

इसके विपरीत, तर्कसंगत संख्या 0.1 , जो कि 1/10 , जैसा कि

  • 0.1 दशमलव में, या
  • 0x1.99999999999999 के रूप में लिखा जा सकता है .. .पी -4 सी -1 99 हेक्सफ्लोट नोटेशन के एक एनालॉग में, जहां ... 9 के एक अंतहीन अनुक्रम का प्रतिनिधित्व करता है।

स्थिरांक 0.2 और 0.3 अपने कार्यक्रम में भी उनके सच्चे मूल्यों के अनुमानों का अनुमान लगाया जाएगा। ऐसा होता है कि निकटतम डबल से 0.2 तर्कसंगत संख्या 0.2 से बड़ा होता है, लेकिन यह निकटतम डबल से < कोड> 0.3 तर्कसंगत संख्या 0.3 से छोटा है। 0.1 और 0.2 का योग तर्कसंगत संख्या 0.3 से बड़ा है और इसलिए आपके कोड में निरंतर से असहमति।

अस्थायी बिंदु अंकगणित मुद्दों का एक काफी व्यापक उपचार है एक आसान-से-पचाने की व्याख्या के लिए, देखें।


javascript - How to capture data and send to server API using angular -


I am using angular for the first time and I am having problems sending back normal data to the server.

I have a server running on the API: http: // localhost: 8080 / lppayment which accepts POST requests and TokenId .

My JS looks like this and is successfully withdrawing a token from the stripe. I just want to send this token to the above mentioned API URL as a POST request.

How can I do this in angular?

'strict use'; Angular.module ('angularDjangoRegistrationAuthApp'). Controller ('TakeMoneyCtrl', function ($ radius, djangoAuth, valid) {$ scope.complete = false; djangoAuth.profile (). Then (function (data) {$ scope.model = data;}); $ scope.handleStripe = Function (status, response) {If there was an error, fix it. Warning ("Error")} Other {// found bar token, now charge it or smt token = response .id warning ("success:" + token);}}});

I just want to send the token to the server, when I successfully get back from the basket back. So I put a warning ("success"); But even that warning is not being shown on the page. Neither is the warning ("error"); However, on Chrome's Networks tab, I can see that the token is actually coming back from the bar. http: // localhost: 8080 / takepayment

question

how can I send the token received from the strip with my API call As an a POST request /

Requires angular $ http service () to inject it and then consume it in your controller Here is a simple example that consumes Kangaroo $ http and one POST

  Angular.module ('Angular digestrationships'). Controller ('techkrutkur', ['$ http', function ($ radius, $ http, DJ, auth, valid) {$ scope.complete = false; djangoAuth.profile (). Then (function (data) {$ scope.model = Data;}); $ Scope.handleStripe = function (position, response) {if (response.error) {// there was an error.} Please correct this. Warning ("Error")} Other {// founder token, You can put it in an object $ http.post var dataModel = {token: response.id}; // in a different service than your $ http post or priority. $ Http.post ('/ someUrl', JSON Error (function (Day (Status, data, position, header, config) {This callback will be called asynchronous / when response is available}.... Is called asynchronously if there is an error / / Server responds with error status.}); Warning ("success:" + token);}}}]);  

There is a way to do this above. But for this, call $ http in a different mascara service and NO Waiting for a response to finish using an JS promise or an expiry of time.

Create a new angular service to handle $ http

  Var app = angular.module ('Connection DegenerationAnthap App', []); App.service ('CommService', ['$ http', function ($ http) {this.processLoginToken = function (token) {var model = {token: token}} var promise = $ http.post ('/ api / Tokenproc ', JSON.stringify (model)) then (function (feedback) {return response.data;}, function (error) {console.log ("communication error, server not answered.");}); Return   

Now outside of your service, you will use it this way.

  var token = "02394924924929424 "; CommService.processLoginToken (token). Then (function (feedback) {// process of your reaction here}}, the function () {// server did not respond.});  

asp.net - Sending string list from Android to vb.net -


Now I am trying to get stuck I send complex data to vb.net WCF service after 2 days. This service request is: From the list & lt;

  Expand class saveLoadParts asyncTask & lt string>, string, string & gt; {@Override protected string doInBackground (list of & lt; string & gt; ... parameter) {from the list & lt; String & gt; Checklist = New Arrestist & lt; String & gt; (); Checklist = Old List; SOAP object request = new SOAP object (NAMESPACE, METHOD_NAME4); Soap-object soapbox = new sapong bag (NAMESPACE, "checklist"); (String i: checklist) {soapLogs.addProperty ("Itemlist", I); } Request.addSoapObject (SOONLogs); SoapSerializationEnvelope envelope = new saponification anaphf (sopenalaphase envelope.setOutputSoapObject (request); envelope.dotNet = true; httpTransportSE transport = new HTTP transcesee (url); {transport.call (GETUSER_SOAP_ACTION + METHOD_NAME4, envelope); try soap reaction feedback = (Sopprimitiv) Lifafakgetrespons (); FinalResult = response.toString ();} catch (Sopfolt e) {e.printStackTrace ();} catch (Acteepiarpispointaksepshn e) {e.printStackTrace ();} catch (IOException e) { E.printStackTrace ();} hold (XmlPullParserException E) {e.printStackTrace ();} eventual return result;} @Override protected void onPostExecute (string result) {if "(lists stored", Toast.LENGTH_SHORT .show () (result.equals ( "{Toast.makeText OrderDetailView .this,))!) ";}}}  

and this is my VB.net code

  public class item list public ABC string End class Return SaveLoadParts (ByVal Suchisuchi as list ()) as string Implements IService1.SaveLoadParts dim as string = checklist (0) KabckToString () functions as a termination problem I have tried almost everything I could possibly find on the internet, it always give me an error. 

  Now I'm getting this Soffolt - Doshkod: a: Desriyalaijeshnfold 'Foltstring' Formetr the message threw an exception while trying to deserialize: parameter was an error while trying to deserialize. InnerException message 'error 1 was in line 361. Element 'http ...' contains a type of data that maps to the name 'http ...'. Deserializer has no knowledge of any kind that is a map for this name. Using a DataContractResolver is the type of idea or type known in the list to add corresponding to the 'checklist'. For example, by using the KnownTypeAttribute attribute or by adding them to the list of types known for the DataContractSerializer. Please see InnerException for more information. 'Mistake:' Zero 'Description: Zero 

Please help!


io - Change from formatted stream I/O to direct I/O in c -


I used this code to use direct I / O instead of writing files, able to change instead of the format stream I want to be? Although I'm not sure how to do this, the help would be greatly appreciated.

  #include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; #Meder100 defined # FORMATREAD "% 12s% 100s% 100s" int main (zero) {FILE * in_ptr, * out_ptr; Four fname [max], lanm [max], number [12]; In_ptr = fopen ("phonelist.txt", "r"); Out_ptr = fopen ("history.txt", "w +"); If ((NULL == in_ptr) || (NULL == out_ptr)) {fputs ("Opening Files, Problems Removing Problems!", Stderr); Exit (1); } If (3 = fscanf (in_ptr, FORMATREAD, number, fname, lname)) {fprintf (out_ptr, "% s% s% s \ n", number, fname, lname); Printf ("% s% s% s \ n", number, fname, lname); Printf ("The phone book has format: name of the phone number \ n"); } And {fprintf (* out_ptr, "unknown type \ n"); Printf ("The phone book has an unknown format \ n"); } Fclose (in_ptr); Fclose (* out_ptr); Return 0; }  

If there are any errors then I have a lot to regretfully coding.

To not use formatted output such as fprintf () , < Create a string in the code> sprintf () or other different ways in the code and write it. It is important that buffer is large enough.

  // fprintf (out_ptr, "% s% s% s \ n", number, fname, lname); // slightly oversize buffer, but it has% s format and variables in the form of four buffer [sizeof number + size fname + sizeof lname + size formatted]; Sprintf (buffer, "% s% s% s \ n", number, FNN, LN); Foots (buffer, out_pTR);  

Concern about fscanf (in_ptr, FORMATREAD, number, fname, lname) exists, which means line Formatted data FORMATREAD does not detects '\ n' as different from '' . Recommend using fgets () to read the data line and then parse it.


The code also needs to improve buffer size and input format

  # max 100 define formatted "% 12s% 100s% 100s" ... four fname [MAX + 1], lname [MAX + 1], number [12 + 1];   

Good code is checking the retrun value from the input function, but instead of == using = @WeatherVane If (3 = fscanf (in_ptr, FORMATREAD, number, fname, lname)) (3 == fscanf (in_ptr, FORMATREAD, number, fname, lname))

>

html5 - Notification api not working -


I have used the HTML5 notification API and saved it as an index on my desktop but after the notification API Clicking on the Permission option also works from demo sites

This link does not work let's check.

I was also running in the same problem while running from file system. // file / desktop like la bla

Then I went to my local server and it worked ...