Posts

Showing posts from May, 2009

Conversion Hex String Into Ascii In Bash Command Line

Answer : This worked for me. $ echo 54657374696e672031203220330 | xxd -r -p Testing 1 2 3$ -r tells it to convert hex to ascii as opposed to its normal mode of doing the opposite -p tells it to use a plain format. This code will convert the text 0xA7.0x9B.0x46.0x8D.0x1E.0x52.0xA7.0x9B.0x7B.0x31.0xD2 into a stream of 11 bytes with equivalent values. These bytes will be written to standard out. TESTDATA=$(echo '0xA7.0x9B.0x46.0x8D.0x1E.0x52.0xA7.0x9B.0x7B.0x31.0xD2' | tr '.' ' ') for c in $TESTDATA; do echo $c | xxd -r done As others have pointed out, this will not result in a printable ASCII string for the simple reason that the specified bytes are not ASCII. You need post more information about how you obtained this string for us to help you with that. How it works: xxd -r translates hexadecimal data to binary (like a reverse hexdump). xxd requires that each line start off with the index number of the first character on the line (run hexdump on som

Power Bi Dax Today - 30 Days Code Example

Example: power bi dax today - 30 days DATEADD ( Dates[Date] , -30 , DAY )

Android - Movable/Draggable Floating Action Button (FAB)

Answer : Based on this answer for another SO question this is the code I have created. It seems to work nicely (with working click functionality) and isn't dependent on the FAB's parent layout or positioning... package com.example; import android.content.Context; import android.support.design.widget.FloatingActionButton; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; public class MovableFloatingActionButton extends FloatingActionButton implements View.OnTouchListener { private final static float CLICK_DRAG_TOLERANCE = 10; // Often, there will be a slight, unintentional, drag when the user taps the FAB, so we need to account for this. private float downRawX, downRawY; private float dX, dY; public MovableFloatingActionButton(Context context) { super(context); init(); } public MovableFloatingActionButton(Context context, AttributeSet attrs) { supe

Rick Astley Never Gonna Give You Up Png Code Example

Example: rick astley - never gonna give you up // https://www.youtube.com/watch?v=dQw4w9WgXcQ

Adding Borders To GridPane JavaFX

Answer : Don't use setGridLinesVisible(true) : the documentation explicitly states this is for debug only. Instead, place a pane in all the grid cells (even the empty ones), and style the pane so you see the borders. (This gives you the opportunity to control the borders very carefully, so you can avoid double borders, etc.) Then add the content to each pane. You can also register the mouse listeners with the pane, which means you don't have to do the ugly math to figure out which cell was clicked. The recommended way to apply a border to any region is to use CSS and a "nested background" approach. In this approach, you draw two (or more) background fills on the region, with different insets, giving the appearance of a border. So for example: -fx-background-fill: black, white ; -fx-background-insets: 0, 1 ; will first draw a black background with no insets, and then over that will draw a white background with insets of 1 pixel on all sides, giving the appea

Printf Unsigned Long Code Example

Example: printf long long int % lld // Signed % llu // Unsigned

How To Update Mysql Data W3schools Php Code Example

Example: MySQL UPDATE The UPDATE statement updates data in a table. It allows you to change the values in one or more columns of a single row or multiple rows. The following illustrates the basic syntax of the UPDATE statement : UPDATE [LOW_PRIORITY] [IGNORE] table_name SET column_name1 = expr1 , column_name2 = expr2 , ... [WHERE condition] ; In this syntax : First , specify the name of the table that you want to update data after the UPDATE keyword. Second , specify which column you want to update and the new value in the SET clause. To update values in multiple columns , you use a list of comma-separated assignments by supplying a value in each column’s assignment in the form of a literal value , an expression , or a subquery. Third , specify which rows to be updated using a condition in the WHERE clause. The WHERE clause is optional. If you omit it , the UPDATE statement will modify all rows in the table.

-nan(ind) C++ Code Example

Example: nan c++ example # include <iostream> # include <cmath> using namespace std ; // main() section int main ( ) { double nanValue ; //generating generic NaN value //by passing an empty string nanValue = nan ( "" ) ; //printing the value cout << "nanValue: " << nanValue << endl ; return 0 ; }

Converting A Spark Dataframe To A Scala Map Collection

Answer : I don't think your question makes sense -- your outermost Map , I only see you are trying to stuff values into it -- you need to have key / value pairs in your outermost Map . That being said: val peopleArray = df.collect.map(r => Map(df.columns.zip(r.toSeq):_*)) Will give you: Array( Map("age" -> null, "name" -> "Michael"), Map("age" -> 30, "name" -> "Andy"), Map("age" -> 19, "name" -> "Justin") ) At that point you could do: val people = Map(peopleArray.map(p => (p.getOrElse("name", null), p)):_*) Which would give you: Map( ("Michael" -> Map("age" -> null, "name" -> "Michael")), ("Andy" -> Map("age" -> 30, "name" -> "Andy")), ("Justin" -> Map("age" -> 19, "name" -> "Justin")) ) I'm guess

Angular - Is There List Of HostListener-Events?

Image
Answer : Open angular dom element schema https://github.com/angular/angular/blob/master/packages/compiler/src/schema/dom_element_schema_registry.ts#L78 where: (no prefix): property is a string. * : property represents an event. ! : property is a boolean. # : property is a number. % : property is an object. Then press ctrl+F and write * @HostListener (and also (customEvent)="handler()" ) can also listen to custom events Example The list of events you can listen to can be found here https://www.w3schools.com/jsref/dom_obj_event.asp and I believe this one is the same, but better organized (I'm not sure if all are valid) https://developer.mozilla.org/en-US/docs/Web/Events Sorry, I think you ask about a list of properties. You can use e.g. @HostListener("focus", ["$event.target"]) onFocus(target) { console.log(target.value) } @HostListener("blur", ["$event.target"]) onBlur(target) { consol

Converting XML To JSON Using Python?

Answer : xmltodict (full disclosure: I wrote it) can help you convert your XML to a dict+list+string structure, following this "standard". It is Expat-based, so it's very fast and doesn't need to load the whole XML tree in memory. Once you have that data structure, you can serialize it to JSON: import xmltodict, json o = xmltodict.parse('<e> <a>text</a> <a>text</a> </e>') json.dumps(o) # '{"e": {"a": ["text", "text"]}}' There is no "one-to-one" mapping between XML and JSON, so converting one to the other necessarily requires some understanding of what you want to do with the results. That being said, Python's standard library has several modules for parsing XML (including DOM, SAX, and ElementTree). As of Python 2.6, support for converting Python data structures to and from JSON is included in the json module. So the infrastructure is there. You can use the

A Command To Get The Sync Status Of A Dropbox File

Answer : Use filestatus : dropbox filestatus /path/to/file For more help see: dropbox help

A Valid Provisioning Profile For This Executable Was Not Found

Answer : Ok, so I solved this, somehow in trying to build for the app store I changed the build config for the "run" scheme from debug to release.. and naturally release was using a distribution cert.. which wasn't (and can't be) installed on my device. I hate xcode 4. (this aspect of it :P) What is a scheme anyway? :S I have a solution as well. This happened to me last night with the exact same error. I had a program that was previously compiling and now that I am adding an update to my app, the same error was displayed. The problem is that I forgot to change my provisioning profile back to Developer. (You set it to Distribution when uploading your app to the App Store). Here are the settings for Xcode 4.6. In your app click Targets -> YourAppName -> Code Signing Identy. Change iPhone Distribution to iPhone Developer. Your app will now compile. 1- TARGETS -> click the app-> Build Setting-> Code Signing : Make sure that both &

4chan (/x/) Code Example

Example 1: 4chan Tumblr is worst and i dont even use either. Example 2: 4chan Remember, this website is the dark hairy asshole of the internet. But sometimes cool stuff happens here.

Bootstrap Logout Icon Code Example

Example: font awesome logout icons < i class = " icon-signout " > </ i > icon-signout

Red Gradient Background Css Code Example

Example: linear-gradient background : linear-gradient ( to left , #333 , #333 50 % , #eee 100 % ) ;

Int To String In CPP Code Example

Example 1: change int to string cpp # include <string> std :: string s = std :: to_string ( 42 ) ; Example 2: c++ int to string # include <string> using namespace std ; int iIntAsInt = 658 ; string sIntAsString = to_string ( iIntAsInt ) ; Example 3: convert int to string c++ int x = 5 ; string str = to_string ( x ) ; Example 4: convert integer to string c++ std :: to_string ( 23213.123 ) Example 5: how to convert int to string c++ # include <iostream> # include <string> using namespace std ; int main ( ) { int i = 11 ; string str = to_string ( i ) ; cout << "string value of integer i is :" << str << "\n" ; return 0 ; } Example 6: c++ int to string // ----------------------------------- C++ 11 and onwards // EXAMPLE # include <string> int iIntAsInt = 658 ; std :: string sIntAsString = to_string ( iIntAsInt ) ; /* SYNTAX to_string(<your

'Connect-MsolService' Is Not Recognized As The Name Of A Cmdlet

Image
Answer : I had to do this in that order: Install-Module MSOnline Install-Module AzureAD Import-Module AzureAD All links to the Azure Active Directory Connection page now seem to be invalid. I had an older version of Azure AD installed too, this is what worked for me. Install this. Run these in an elevated PS session: uninstall-module AzureAD # this may or may not be needed install-module AzureAD install-module AzureADPreview install-module MSOnline I was then able to log in and run what I needed. This issue can occur if the Azure Active Directory Module for Windows PowerShell isn't loaded correctly. To resolve this issue, follow these steps. 1. Install the Azure Active Directory Module for Windows PowerShell on the computer (if it isn't already installed). To install the Azure Active Directory Module for Windows PowerShell, go to the following Microsoft website: Manage Azure AD using Windows PowerShell 2.If the MSOnline module isn't present, use Windows PowerShell to i

Access Logs From Console.log() In Node.js Vm Module

Answer : You can just wrap console.log directly: function hook_consolelog(callback) { var old_log = console.log; console.log = (function(write) { return function() { write.apply(console, arguments) callback.apply(null, arguments); } })(console.log) return function() { console.log = old_log; } } var result; var unhook = hook_consolelog(function(v) { result = v; }); console.log('hello'); unhook(); console.log('goodbye'); console.log('the result is ', result);​ Since console.log simply calls process.stdout , another approach would be to capture the stdout events using a bit of wrapper magic like this: var util = require('util') function hook_stdout(callback) { var old_write = process.stdout.write process.stdout.write = (function(write) { return function(string, encoding, fd) { write.apply(process.stdout, arguments) callback(string,

Can I Remove A RAR File's (known) Password Without Recompressing The Archive?

Answer : Out of the box, no, you can not. Version 3 of the RAR file format (implemented first in WinRAR 2.9) encrypts the actual data itself, as well as the file headers (if requested) using AES-128 encryption. With just WinRAR, it is impossible to simply "remove" the password from an archive, since the data itself is encrypted with the password. You could make a quick batchfile implementing a "remove password" feature, which could simply unrar the archive, and then re-compress the files without a password. Technically , the data is compressed before being encrypted. This indicates that, given enough knowledge of the RAR file format itself, one could create a tool to AES-decrypt the datastream of the compressed files, and then save it into a new RAR archive. It should be noted, however, that this requires extensive knowledge of the file format itself. Given the number of open-source tools that support password-protected RAR files (e.g. unar), one c