Posts

Showing posts from April, 2016

Can A 2-prong AC/DC Converter Switch Polarity Based On Inverting The Plug?

Image
Answer : This circuit will do what you want (for a literal interpretation of the question): No way. Given just a differential, just a pair of connections, there's no way for a circuit to tell which is which. If you had access to phase information about the grid, you might be able to do it, but as the mains frequency isn't terribly constant, you would not be able to rely on predicting this. Your device would have to get information about the present phase angle of the mains from someplace. However, if you do have a real earth-ground reference from some place, you could build a circuit to look at the voltage of each supply line with respect to ground. One will be a small drop below the full 120 (or whatever the local mains supply) whereas the other will be slightly above ground. (Neutral return current vs your neutral run's resistance). This would just let you know which leg was 'hot', and you could swap your output polarity accordingly. A Second Thought

Chart.js Doughnut With Rounded Edges

Image
Answer : You can extend the chart to do this Preview Script Chart.defaults.RoundedDoughnut = Chart.helpers.clone(Chart.defaults.doughnut); Chart.controllers.RoundedDoughnut = Chart.controllers.doughnut.extend({ draw: function (ease) { var ctx = this.chart.chart.ctx; var easingDecimal = ease || 1; Chart.helpers.each(this.getDataset().metaData, function (arc, index) { arc.transition(easingDecimal).draw(); var vm = arc._view; var radius = (vm.outerRadius + vm.innerRadius) / 2; var thickness = (vm.outerRadius - vm.innerRadius) / 2; var angle = Math.PI - vm.endAngle - Math.PI / 2; ctx.save(); ctx.fillStyle = vm.backgroundColor; ctx.translate(vm.x, vm.y); ctx.beginPath(); ctx.arc(radius * Math.sin(angle), radius * Math.cos(angle), thickness, 0, 2 * Math.PI); ctx.arc(radius * Math.sin(Math.PI), radius * Math.cos(Math.

Access Denied For User 'root'@'localhost' (using Password: YES) - No Privileges?

Answer : If you have that same problem in MySql 5.7.+ : Access denied for user 'root'@'localhost' it's because MySql 5.7 by default allow to connect with socket, which means you just connect with sudo mysql . If you run sql : SELECT user,authentication_string,plugin,host FROM mysql.user; then you will see it : +------------------+-------------------------------------------+-----------------------+-----------+ | user | authentication_string | plugin | host | +------------------+-------------------------------------------+-----------------------+-----------+ | root | | auth_socket | localhost | | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | debian-sys-maint | *497C3D7B50479A812B89CD12EC3

Change The Font Size Of Visual Studio Solution Explorer

Answer : Go to Tools->Options->Environment->Fonts and Colors In "Show Settings for" chose "Environment Font" In "Font" replace Automatic to for example, Arial and change size. Change the font size of that setting, all Font size in the Explorers (Solution Explorer, Server Explorer and Toolbox) and menus will change. You can set that in Tools, Options.

Black Overlay Css Code Example

Example 1: make background overlay css #element-with-background-image { position : relative ; background-image : url ( "//spin.atomicobject.com/wp-content/uploads/20170324102432/portfolio-tips-feature-image.jpg" ) ; } #color-overlay { position : absolute ; top : 0 ; left : 0 ; width : 100 % ; height : 100 % ; background-color : black ; opacity : 0.6 ; } Example 2: make background overlay css <div id= "element-with-background-image" > <div id= "color-overlay" ></div> ... </div>

Byg Minecraft Mod Code Example

Example: what is a minecraft mod A Minecraft mod is a .jar type file, when used in combination with a Modloader like forge that mod will have the power to add/remove/edit features of the default game, EG a horse mod could add many new breeds of horse A space mod (galacticraft is EPIC) could add new planets and spaceships

6ix9ine - Gooba (lyrics) Code Example

Example: gooba lyrics LESS GOOOOOOOOOOOOOOO

Auto Create A Test File In Angular Code Example

Example: auto create a test file in angular $ npm install ngentest - g # to run this command anywhere$ ngentest my . component . ts

Bootstrap 3 Hide On Mobile Code Example

Example 1: display sm none Hidden on all .d-none Hidden only on xs .d-none .d-sm-block Hidden only on sm .d-sm-none .d-md-block Hidden only on md .d-md-none .d-lg-block Hidden only on lg .d-lg-none .d-xl-block Hidden only on xl .d-xl-none Visible on all .d-block Visible only on xs .d-block .d-sm-none Visible only on sm .d-none .d-sm-block .d-md-none Visible only on md .d-none .d-md-block .d-lg-none Visible only on lg .d-none .d-lg-block .d-xl-none Visible only on xl .d-none .d-xl-block Example 2: bootstrap hide only on mobile < p class = " d-none d-sm-block " > Hidden only on mobile </ p > Example 3: bootstrap display inline block < div class = " d-inline-block " > </ div > Example 4: bootstrap display none <!-- Bootstrap 4 --> < div class = " d-none " > </ div > <!-- Bootstrap 3 --> <!-- <div class="hidden-{screen size}"></div> --> < div class = " hidden

How To Extract Data From Xml File Using Python Code Example

Example: how to read ome xml file in python showinf - omexml - only / path / to / file / myFile . ome . tif >> path / to / output / myFile . ome . xml

22 Cm In Inches Code Example

Example: cm to inch 1 cm = 0.3937 inch

ADB Over Wireless

Answer : Rooting is not required. With USB cable connected, port 5555 opened across all involved firewalls and debug mode enabled adb tcpip 5555 then look into wireless properties of your device and the network you use, to see which IP address have been granted to device (or configure your DHCP always to use the same for the device mac address). Then adb connect 192.168.1.133 (were 192.168.1.133 is a sample IP address). This is all. You can now use adb shell or adb install or adb upload or the like with USB cable plugged out. To switch back to USB mode, adb usb The device may also revert back to USB mode after reboot. This mode is needed for development of applications that use attached USB devices directly (USB port is used by device so cannot be used by ADB). It is briefly covered in the USB debugging section of the Android website. I ran into the same problem today and find that things are fine on my non-rooted 4.2 Galaxy Nexus device, but does not work on m

AngularJS $broadcast With Multiple Parameters

Answer : Just put the parameters into an object: $scope.$broadcast('event', { a: item1, b: item2 }) Then access them from the second argument to the callback: $scope.$on('event', function(event, opt) { // access opt.a, opt.b }); Or if using ES2015 syntax you can unpack the arguments: $scope.$on('event', (event, {a,b}) => { // access them just as a, b }); Documentation says: 'Optional one or more arguments which will be passed onto the event listeners' $rootScope.$emit(event_name, p1, p2, p3);

Can A Google Sheets Custom Menu Pass A Variable To Function?

Answer : When you create a menu item with .addItem('Nathaniel MacIver', menuItem2('nm@emailaddress.com')) the function menuItem2 is called with the parameter 'nm@emailaddress.com'. This results in the alert that you see. The return value of the function is undefined (as you don't return anything from it). So you end up with the same menu item as if it was .addItem('Nathaniel MacIver', undefined) which clearly isn't going to do anything. The method addItem takes only a function name, it does not allow for passing parameters to that function. To do what you want, you'll need separate functions for each person, each with an email hardcoded inside that function. Although you can't pass functions that invoke with a variable directly through the .addItem() method, because it only accepts strings, you can take a couple of extra steps (extra steps relative to what you were trying to do) to dynamically create functions that are pre-s

Avoid Page Breaks In \lstlistings

Answer : Wrapping the lstlisting inside a minipage (of width \linewidth ) boxes the content making it unbreakable and avoids breaking across the page boundary: ... \begin{minipage}{\linewidth} \begin{lstlisting} static boolean abcde ( abc_defg_hijk * const lm ); \end{lstlisting} \end{minipage} ... Depending on the location of usage, you may have to prepend the environment with \noindent to avoid any paragraph indentation. A somewhat similar approach is followed if you load the float package and use ... \begin{lstlisting}[float,floatplacement=H] static boolean abcde ( abc_defg_hijk * const lm ); \end{lstlisting} ... More on the float placement H is discussed in How to influence the position of float environments like figure and table in LaTeX? I'm using version 1.5 (2013) of the listings package. I use lstinputlisting to include the code from the file, and I just put float inside the options of the environment. It works fine. For example, this goes in my

Bootstrap 3 - Print / PDF

Answer : I'm most case i will expect the print in the non horizontal version maybe? In your case you could try to apply the grid rules on the print media query. In the case you use the small grid (col-sm-*) default, b.e. <div class="container"> <div class="row"> <div class="col-sm-6">Left</div> <div class="col-sm-6">Right</div> </div> </div> <!-- /container --> In your grid.less replace @media (min-width: @screen-tablet) { with @media (min-width: @screen-tablet), print { (add print, see: CSS media queries: max-width OR max-height) Recompile bootstrap and your pdf will have left / right just like screen now. Without Less you could try to add specific css rules for your case like: @media print { body {width:1200px;} div[class|=col-]{float:left;} .col-sm-6{width:50%} } Note print.less contains specific rules for print media. This i

ClassLoader GetResourceAsStream Returns Null

Answer : If it's in the same package use InputStream is = Driver.class.getResourceAsStream("myconfig.txt"); The way you have it InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("myconfig.txt"); It's looking for the file in the root of the classpath. You could use InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("com/me/myapp/myconfig.txt"); The rules for searching are explained in the javadoc of ClassLoader#getResource(String) and the javadoc of Class#getResource(String) . If you are working with Maven, add the following lines under BUILD tag. You get this error when you are running the webapp on server but there is no reference to the resources on the server. So, add this the following into your POM.xml and see the magic. <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <

Array Length Arduino Code Example

Example: length arduino String myString = "text"; //make a stirng int stringLength = myString.length(); //get length from string

Check If A String Is Not NULL Or EMPTY

Answer : if (-not ([string]::IsNullOrEmpty($version))) { $request += "/" + $version } You can also use ! as an alternative to -not . You don't necessarily have to use the [string]:: prefix. This works in the same way: if ($version) { $request += "/" + $version } A variable that is null or empty string evaluates to false. As in many other programming and scripting languages you can do so by adding ! in front of the condition if (![string]::IsNullOrEmpty($version)) { $request += "/" + $version }

Bootstrap 4 Use A Href As Form Submit Button Code Example

Example 1: bootstarp btn colors < button type = "button" class = "btn btn-primary" > Blue < /button > < button type = "button" class = "btn btn-secondary" > Grey < /button > < button type = "button" class = "btn btn-success" > Green < /button > < button type = "button" class = "btn btn-danger" > Red < /button > < button type = "button" class = "btn btn-warning" > Yellow < /button > < button type = "button" class = "btn btn-info" > Ligth blue < /button > < button type = "button" class = "btn btn-light" > White < /button > < button type = "button" class = "btn btn-dark" > Black < /button > < button type = "button" class = "btn btn-link" > White with blue text < /button > Example 2:

Bootstrap Burger Dropdown Button Navbar Example

Example: navbar right bootstrap 4 < nav class = " navbar navbar-expand-lg navbar-light bg-light " > < a class = " navbar-brand " href = " # " > Navbar </ a > < button class = " navbar-toggler " type = " button " data-toggle = " collapse " data-target = " #navbarSupportedContent " aria-controls = " navbarSupportedContent " aria-expanded = " false " aria-label = " Toggle navigation " > < span class = " navbar-toggler-icon " > </ span > </ button > < div class = " collapse navbar-collapse " id = " navbarSupportedContent " > < ul class = " navbar-nav mr-auto " > < li class = " nav-item active " > < a class = " nav-link " href = " # " > Home < span class = " sr-only " > (current) <

Class 0 SMS (flash SMS) On Android

Answer : For rooted Android it is possible to bypass an API and send Class 0 SMS. There is a project on Git Hub called ZeroSMS: ZeroSMS is a proof-of-concept demonstrating a way to send Class 0 SMS on android >=2.3. Note: this only works on versions 2.2 -> 4.1.2, the sendRawPdu method was removed, so you will need to find a new way to do this. It was possible to send Flash SMS (that's the term for class 0 SMS) before Android 2.2. Google removed the sendRawPdu API, so even if you used reflection, you wouldn't be able to do it. Here's how I did it previously (this was tested on Android 1.6 and worked) private void sendSms(String phone, String sms) { if ((phone == null) || (sms == null) || (phone.length() == 0) || (sms.length() == 0)) { String message = "Phone or message empty!!!"; Toast notification = Toast.makeText(getBaseContext(), message, Toast.LENGTH_SHORT); notification.show();