Posts

Showing posts from December, 2014

Center Expanded ListView Inside Column Flutter

Image
Answer : The ListView fills the entire Expanded Widget, that's why using the Center widget didn't work, so shrinkWrap: true should be added so the ListView takes only the height of it's children. After skimming through the documentation I found about Flexible Widget Flexible, which does not force the child to fill the available space. Made the change and works like a charm Flexible( child: ListView.builder( shrinkWrap: true, itemCount: 4, itemBuilder: (BuildContext context, int index) => CustomAppText( text: 'Custom App', ), ), ), For those still looking for an answer, this is what worked for me: Column( children: [ Container(), // some top content Expanded( child: Center( child: ListView( shrinkWrap: true, children: [] //your list view co

Alert Success Message In Bootstrap Code Example

Example 1: bootstrap alert < div class = "alert alert-primary" role = "alert" > This is a primary alert—check it out ! < / div > < div class = "alert alert-secondary" role = "alert" > This is a secondary alert—check it out ! < / div > < div class = "alert alert-success" role = "alert" > This is a success alert—check it out ! < / div > < div class = "alert alert-danger" role = "alert" > This is a danger alert—check it out ! < / div > < div class = "alert alert-warning" role = "alert" > This is a warning alert—check it out ! < / div > < div class = "alert alert-info" role = "alert" > This is a info alert—check it out ! < / div > < div class = "alert alert-light" role = "alert" > This is a light alert—check it out ! < /

Change Default Font SSRS Visual Studio

Answer : Unfortunately by design, you are not allowed to set default font etc. There is active defect in Microsoft https://connect.microsoft.com/SQLServer/feedback/details/574003/modify-the-default-font-family-for-sql-server-business-intelligence-development-studio-while-creating-a-report# I know it's a very old post, but for others in search of an answer, I thought I'd add the following. If I want all my textboxes in a font other than Arial 10pt, I will make the first textbox and set my font styling, then use that as a master textbox, copying it and changing the interior text rather than creating new textboxes each time. It's a hack, but since VS still can't do this in 2015, it's the best we have. You can always open code(XML)-view and edit font properties there. Eg. search for <FontFamily> -tag and add <FontSize>10pt</FontSize> as a sibling for <Style>-tag. Before editing the XML, close report design-view. Otherwise propert

Assign User-objects To A Group While Editing Group-object In Django Admin

Answer : The save method above won't work if you add a new group and simultaneously add users to the group. The problem is that the new group won't get saved (the admin uses commit=False) and won't have a primary key. Since the purpose of save_m2m() is to allow the calling view to handle saving m2m objects, I made a save object that wraps the old save_m2m method in a new method. def save(self, commit=True): group = super(GroupAdminForm, self).save(commit=commit) if commit: group.user_set = self.cleaned_data['users'] else: old_save_m2m = self.save_m2m def new_save_m2m(): old_save_m2m() group.user_set = self.cleaned_data['users'] self.save_m2m = new_save_m2m return group yourapp/admin.py from django import forms from django.contrib import admin from django.utils.translation import ugettext_lazy as _ from django.contrib.admin.widgets import FilteredSelectMultiple from django.contr

Bootstrap Registration Form With Validation Codepen Code Example

Example: form validation javascript bootstrap < script > // Example starter JavaScript for disabling form submissions if there are invalid fields ( function ( ) { 'use strict' ; window . addEventListener ( 'load' , function ( ) { // Fetch all the forms we want to apply custom Bootstrap validation styles to var forms = document . getElementsByClassName ( 'needs-validation' ) ; // Loop over them and prevent submission var validation = Array . prototype . filter . call ( forms , function ( form ) { form . addEventListener ( 'submit' , function ( event ) { if ( form . checkValidity ( ) === false ) { event . preventDefault ( ) ; event . stopPropagation ( ) ; } form . classList . add ( 'was-validated' ) ;

BackgroundSize: "cover" Code Example

Example 1: background image size css #example1 { background: url(mountain.jpg); background-repeat: no-repeat; background-size: auto; } #example2 { background: url(mountain.jpg); background-repeat: no-repeat; background-size: 300px 100px; } Example 2: css background full width body { background: url(img/bg-image.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }

Heap Geeksforgeeks C++ Code Example

Example 1: min heap in c++ priority_queue < int , vector < int > , greater < int >> minHeap ; Example 2: max heap c++ # include <iostream> using namespace std ; void max_heap ( int * a , int m , int n ) { int j , t ; t = a [ m ] ; j = 2 * m ; while ( j <= n ) { if ( j < n && a [ j + 1 ] > a [ j ] ) j = j + 1 ; if ( t > a [ j ] ) break ; else if ( t <= a [ j ] ) { a [ j / 2 ] = a [ j ] ; j = 2 * j ; } } a [ j / 2 ] = t ; return ; } void build_maxheap ( int * a , int n ) { int k ; for ( k = n / 2 ; k >= 1 ; k -- ) { max_heap ( a , k , n ) ; } } int main ( ) { int n , i ; cout << "enter no of elements of array\n" ; cin >> n ; int a [ 30 ] ; for ( i = 1 ; i <= n ; i ++ ) { cout << "enter ele

Chart Js Bar Line Color Code Example

Example: chartjs line color backgroundColor : '' , borderColor : ''

Angular: Convert XML To JSON

Image
Answer : If you use angular-cli to bootstrap your application - it comes already with node module to convert xml. https://github.com/Leonidas-from-XIV/node-xml2js So you do not need to add extra modules for this. As it is classic commonJS module - you need use require to import it: let parseString = require('xml2js').parseString; So your code can looks like: let parseString = require('xml2js').parseString; let xml = "<root>Hello xml2js!</root>" parseString(xml, function (err, result) { console.dir(result); }); You will receive next output: In any cases - if you even do not use angular-clior want to use your preffered module to parse xml - use require to load it. function parseXml(xmlStr) { var result; var parser = require('xml2js'); parser.Parser().parseString(xmlStr, (e, r) => {result = r}); return result; }

Codecademy Courses Free Download Code Example

Example 1: code A Code in Computer is what You write to Run Machines / Websites or Applications Example 2: Codecademy welcome to heaven !!

Arduino DigitalRead Reading Wrong

Answer : What you have is called a Floating pin. Digital Input pins are very sensitive to change, and unless positively driven to one state or another (High or Low), will pick up stray capacitance from nearby sources, like breadboards, human fingers, or even the air. Any wire connected to it will act like a little antenna and cause the input state to change. And I mean any wire, the trace on the board, the wire to the breadboard, the breadboard pin, even the metal pin of the IC itself. This is refereed to in the Arduino reference page: If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly). If you look at the Arduino Digital Pin Tutorial: This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupli

Bootstrap Fa Icons Code Example

Example: release icon font awesome < i class = " fa fa-rocket " aria-hidden = " true " > </ i >

Android Scale Button On Touch

Answer : Try the following: @Override public boolean onTouch(View v, MotionEvent motionEvent) { int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_DOWN) { v.animate().scaleXBy(100f).setDuration(5000).start(); v.animate().scaleYBy(100f).setDuration(5000).start(); return true; } else if (action == MotionEvent.ACTION_UP) { v.animate().cancel(); v.animate().scaleX(1f).setDuration(1000).start(); v.animate().scaleY(1f).setDuration(1000).start(); return true; } return false; } This should do the trick ;)

Axions Npm Code Example

Example: how to install axios in react $ npm install axios

Can You Split A Stream Into Two Streams?

Answer : A collector can be used for this. For two categories, use Collectors.partitioningBy() factory. This will create a Map from Boolean to List , and put items in one or the other list based on a Predicate . Note: Since the stream needs to be consumed whole, this can't work on infinite streams. And because the stream is consumed anyway, this method simply puts them in Lists instead of making a new stream-with-memory. You can always stream those lists if you require streams as output. Also, no need for the iterator, not even in the heads-only example you provided. Binary splitting looks like this: Random r = new Random(); Map<Boolean, List<String>> groups = stream .collect(Collectors.partitioningBy(x -> r.nextBoolean())); System.out.println(groups.get(false).size()); System.out.println(groups.get(true).size()); For more categories, use a Collectors.groupingBy() factory. Map<Object, List<String>> groups = stream

Apple - Are There Greasemonkey Scripts For Safari?

Answer : Another option to run GreaseMonkey scripts is NinjaKit (which is what I use). It's a Safari 5 extension, which means it's just a tad safer than GreaseKit. I use TamperMonkey and it works surprisingly well. It's also a Safari Extension. I have tried used NinjaKit in the past but it no longer works for me, a lot of scripts simply won't work. Is there such a thing as Greasemonkey for Safari? You can use SIMBL and GreaseKit to run most Greasemonkey scripts in Safari, unmodified. Detailed installation instructions are found at this link, repeated here: Download and install SIMBL Quit Safari Download GreaseKit Drag the GreaseKit.bundle file to ~/Library/Application Support/SIMBL/Plugins . You may need to create this location if it doesn't exit Start Safari and you'll see a GreaseKit menu bar item Install scripts from http://userscripts.org -- the installation process is a little different from the Firefox approach, but it works. Or

Open Local Pdf File In Webview Android Code Example

Example: read pdf web on android webView . loadUrl ( "https://docs.google.com/viewer?url=" + "url of pdf file" ) ;

Backtick Character In Keyboard Code Example

Example 1: backtick # A backtick ` Example 2: ` Alternatively known as acute, backtick, left quote, or an open quote, the back quote or backquote is a punctuation mark (`).

Cmd /c Pause Code Example

Example: programming c pause # include <unistd.h> // your code here sleep ( 3 ) ; // sleep for 3 seconds

What Is The Data Structure Used To Perform Recursion (1 Point) Code Example

Example: recursion data structure int function ( int value ) { if ( value < 1 ) return ; function ( value - 1 ) ; printf ( "%d " , value ) ; }

Git Reset Local Changes Code Example

Example 1: git discard local changes # Discarding local changes ( permanently ) to a file : git checkout -- < file > # Discard all local changes to all files permanently : git reset -- hard Example 2: git undo all changes git reset -- hard Example 3: undo unstaged changes git git checkout -- . Example 4: git reset one file git checkout HEAD -- my - file . txt Example 5: revert unstaged changes git git checkout -- path / to / file / to / revert Example 6: git discard staged changes git reset HEAD git checkout .