Posts

Showing posts from October, 2016

Android Studio Flutter Build Apk Code Example

Example 1: flutter apk build flutter build apk -- split - per - abi Example 2: flutter build android release apk small flutter build apk -- split - per - abi Example 3: sign flutter app android studio keytool - genkey - v - keystore c : / Users / USER_NAME / key . jks - storetype JKS - keyalg RSA - keysize 2048 - validity 10000 - alias key Example 4: flutter signed apk keytool - genkey - v - keystore ~ / key . jks - keyalg RSA - keysize 2048 - validity 10000 - alias key

Naive String Matching Algorithm Geeksforgeeks. Code Example

Example: naive pattern matching algorithm # include <bits/stdc++.h> using namespace std ; void search ( char * pat , char * txt ) { int M = strlen ( pat ) ; int N = strlen ( txt ) ; /* A loop to slide pat[] one by one */ for ( int i = 0 ; i <= N - M ; i ++ ) { int j ; /* For current index i, check for pattern match */ for ( j = 0 ; j < M ; j ++ ) if ( txt [ i + j ] != pat [ j ] ) break ; if ( j == M ) // if pat[0...M-1] = txt[i, i+1, ...i+M-1] cout << "Pattern found at index " << i << endl ; } }

Change Bootstrap 4 Checkbox Size

Answer : There is currently an issue with this and I reported it to Bootstrap. Until that's fixed do the following: First of all, use the form-control-lg class. Once the issue is fixed using that class will be all you need. Until the issue is fixed add the following css: .custom-control-label::before, .custom-control-label::after { top: .8rem; width: 1.25rem; height: 1.25rem; } Here's a complete working code example: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous"> <style> .custom-control-label::before, .custom-control-label::after { top: .8rem; width: 1.25rem; height: 1.25rem; } </style> <div class="custom-control form-control-lg custom-checkbox"> <input type="checkbox" class="custom-co

2. Write A C Program Using Functions To Convert Binary Number To Decimal And Vice-versa Code Example

Example 1: built in function in c++ for binary to decimal # include <bits/stdc++.h> using namespace std ; int main ( void ) { bitset < 8 > bits ( "1000" ) ; int ab = bits . to_ulong ( ) ; cout << ab << "\n" ; return 0 ; } Example 2: binary to decimal in c # include <math.h> # include <stdio.h> int convert ( long long n ) ; int main ( ) { long long n ; printf ( "Enter a binary number: " ) ; scanf ( "%lld" , & n ) ; printf ( "%lld in binary = %d in decimal" , n , convert ( n ) ) ; return 0 ; } int convert ( long long n ) { int dec = 0 , i = 0 , rem ; while ( n != 0 ) { rem = n % 10 ; n /= 10 ; dec += rem * pow ( 2 , i ) ; ++ i ; } return dec ; }

Bash Throws Error, Line 8: $1: Unbound Variable

Answer : set -u will abort exactly as you describe if you reference a variable which has not been set. You are invoking your script with no arguments, so get_percent is being invoked with no arguments, causing $1 to be unset. Either check for this before invoking your function, or use default expansions ( ${1-default} will expand to default if not already set to something else). This is the effect of set -u . You could check $# inside the function and avoid referencing $1 if it is not set. With $# you can access the number of parameters. In global context it is the number of parameters to the script, in a function it is the number of parameters to the function. In the context of the question, it is if [ $# -ge 1 ] && [ -n "$1" ] then df -h $1 | tail -n +2 | awk '{ print $1,"\t",$5 }' else df -h | tail -n +2 | awk '{ print $1,"\t",$5 }' fi Note that you have to use [ $# -ge 1 ] && [ -n "$

Bootstrap Navbar Dropdown Header Code Example

Example: navbar bootstrap 4 with dropdown < 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 " > (curr

Atob Nodejs Import Code Example

Example: nodejs btoa Buffer . from ( 'Hello world!' , 'binary' ) . toString ( 'base64' )

Cannot Uninstall Angular-cli

Answer : I have also faced the same issue in recent past for me I have do the following commands one by one in terminal. sudo npm uninstall -g angular-cli sudo npm cache clean After this run ng -v If still get angular-cli version 1.0.0-beta.2x.x then run the following command which ng It will show the ng path. Go to the path and if it is linked with any file remove the same the link and actual ng file. In my case the link is in /usr/bin/ng and actual path of ng file is /lib/node_modules/@angular/cli/bin/ng. sudo rm -rf /lib/node_modules/@angular/cli/bin/ng sudo rm -rf /usr/bin/ng Next you need to install @angular/cli using sudo npm install -g @angular/cli Close all the terminal and run ng -v and you are on. May be it will help someone. Thanks :) Updating Angular CLI https://github.com/angular/angular-cli#updating-angular-cli If you're using Angular CLI 1.0.0-beta.28 or less, you need to uninstall angular-cli package first. npm uninstall -g angular-cli

Can I Use An HTML Input Type "date" To Collect Only A Year?

Answer : No you can not but you may want to use input type number as a workaround. Look at the following example: <input type="number" min="1900" max="2099" step="1" value="2016" /> No, you can't, it doesn't support only year, so to do that you need a script, like jQuery or the webshim link you have, which shows year only. If jQuery would be an option, here is one, borrowed from Sibu: Javascript $(function() { $( "#datepicker" ).datepicker({dateFormat: 'yy'}); });​ CSS .ui-datepicker-calendar { display: none; } Src: https://stackoverflow.com/a/13528855/2827823 Src fiddle: http://jsfiddle.net/vW8zc/ Here is an updated fiddle, without the month and prev/next buttons If bootstrap is an option, check this link, they have a layout how you want. There is input type month in HTML5 which allows to select month and year. Month selector works with autocomplete. Check the examp

Bootstrap Mobile Menu Icon Change To X Close

Answer : Your JavaScript replaces the inner html of the #ChangeToggle element to show either the X or the hamburger icon. Precisely clicking on the X or the hamburger menu instead of the #ChangeToggle will remove the element being clicked on which I think prevents it from bubbling up. As Bootstrap's collapse plugin uses an event handler on the document to determine if an element has been clicked, the collapse plugin will never get notified. I've created a small example where a click handler on the pink .outer area replaces the green .inner area. Note that clicking on the pink area (your #ChangeToggle ) will lead to two events, where clicking on the green area (your X icon) will lead to a single event. $(function() { $('.outer') .click(function() { $('.outer').html('<div class="inner"></div>'); fired('.js-outer'); }); $(document).on('click', '.outer', function() { fire

Css Checkbox Size Code Example

Example 1: css resize checkbox input [ type = checkbox ] { transform : scale ( 1.5 ) ; } Example 2: input checkbox size css input [ type = checkbox ] { transform : scale ( 1.5 ) ; } < label > < input type = "checkbox" > Test < / label > Example 3: css percent scale checkbox // to scale checkboxes with the rest of the page use this: //Note, use width percent, height auto and the scale command inside another div as a ref < div style = "width:100%; height:auto;" > < input type = "checkbox" style = "width:20%; height:auto; transform: scale(2.5);" > < / div > Example 4: update checkbox size css input . /*checkbox class name*/ { width : /*preferred width*/ ; height : /*preferred height*/ ; }

Type Casting In Oop Javatpoint Code Example

Example 1: java type casting // You can typecast to convert a variable of one data type to another. // Wide Casting converts small data types to larger ones. // Narrow Casting converts large data types to smaller ones. // Java can automatically Wide Cast. // Java will throw an error when trying to automatically Narrow Cast. // This is because data is often lost when Narrow Casting. // Narrow Casting must be done manually. //Wide Cast: int SomeNumber = 5 ; double WideCastedNumber = ( double ) SomeNumber ; //Narrow Cast: double SomeNumber = 5.39 ; int NarrowCastedNumber = ( int ) SomeNumber ; //Note: The data that holds the decimal places will be lost! Example 2: cast java JAVA : Example of cast : int SomeNumber = 5 ; //int double WideCastedNumber = ( double ) SomeNumber ; //from int to double double myDouble = 9.78 ; int myInt = ( int ) myDouble ; // from double to int

Alterning Cumn In Sql Code Example

Example 1: sql add column ALTER TABLE Customers ADD Email varchar ( 255 ) ; Example 2: alter table add column ALTER TABLE table_name ADD column_name datatype ;

"̢۪" Showing On Page Instead Of " ' "

Answer : So what's the problem, It's a ’ ( RIGHT SINGLE QUOTATION MARK - U+2019) character which is being decoded as CP-1252 instead of UTF-8. If you check the encodings table, then you see that this character is in UTF-8 composed of bytes 0xE2 , 0x80 and 0x99 . If you check the CP-1252 code page layout, then you'll see that each of those bytes stand for the individual characters â , € and ™ . and how can I fix it? Use UTF-8 instead of CP-1252 to read, write, store, and display the characters. I have the Content-Type set to UTF-8 in both my <head> tag and my HTTP headers: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> This only instructs the client which encoding to use to interpret and display the characters. This doesn't instruct your own program which encoding to use to read, write, store, and display the characters in. The exact answer depends on the server side platform / database / progra

Python Gcd Of Three Numbers Code Example

Example: python code for gcd of two numbers # Function to find HCF the Using Euclidian algorithm def compute_hcf ( x , y ) : while ( y ) : x , y = y , x % y return x hcf = compute_hcf ( 300 , 400 ) print ( "The HCF is" , hcf )

C# Bootstrap Pagination In ASP.NET Gridview Pager Style?

Image
Answer : I know this is old, But I found something, which is a css style, simple easy and fast https://sufiawan.wordpress.com/2014/09/26/asp-net-use-bootstrap-pagination-on-gridview/ I hope it will save someone sometime. update: *In case the link is down: You add the CSS .pagination-ys { /*display: inline-block;*/ padding-left: 0; margin: 20px 0; border-radius: 4px; } .pagination-ys table > tbody > tr > td { display: inline; } .pagination-ys table > tbody > tr > td > a, .pagination-ys table > tbody > tr > td > span { position: relative; float: left; padding: 8px 12px; line-height: 1.42857143; text-decoration: none; color: #dd4814; background-color: #ffffff; border: 1px solid #dddddd; margin-left: -1px; } .pagination-ys table > tbody > tr > td > span { position: relative; float: left; padding: 8px 12px; line-height: 1.42857143; text-decoration: non

Error: 'nullptr' Was Not Declared In This Scope Code Example

Example: declare nullptr c++ int * ptr = NULL ;

Base64 String To Pdf Download In Java Code Example

Example: convert base64 to pdf in java import java . io . File ; import java . io . FileOutputStream ; import java . util . Base64 ; class Base64DecodePdf { public static void main ( String [ ] args ) { File file = new File ( "./test.pdf" ) ; try ( FileOutputStream fos = new FileOutputStream ( file ) ; ) { // To be short I use a corrupted PDF string, so make sure to use a valid one if you want to preview the PDF file String b64 = "JVBERi0xLjUKJYCBgoMKMSAwIG9iago8PC9GaWx0ZXIvRmxhdGVEZWNvZGUvRmlyc3QgMTQxL04gMjAvTGVuZ3==" ; byte [ ] decoder = Base64 . getDecoder ( ) . decode ( b64 ) ; fos . write ( decoder ) ; System . out . println ( "PDF File Saved" ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } }

164 Cm In Inches In Feet Code Example

Example 1: cm to inches 1 cm = 0.393701 inch Divide the cm value by 2.54. Example 2: cm to inches const cm = 1; console.log(`cm:${cm} = in:${cmToIn(cm)}`); function cmToIn(cm){ var in = cm/2.54; return in; }

Base Table Or View Not Found: 1146 Table Laravel 5

Answer : I'm guessing Laravel can't determine the plural form of the word you used for your table name. Just specify your table in the model as such: class Cotizacion extends Model{ public $table = "cotizacion"; Check your migration file, maybe you are using Schema::table, like this: Schema::table('table_name', function ($table) { // ... }); If you want to create a new table you must use Schema::create: Schema::create('table_name', function ($table) { // ... }); I faced this problem too in laravel 5.2 and if declaring the table name doesn't work,it is probably because you have some wrong declaration or mistake in validation code in Request (If you are using one)

Android Horizontal RecyclerView Scroll Direction

Answer : Assuming you use LinearLayoutManager in your RecyclerView, then you can pass true as third argument in the LinearLayoutManager constructor. For example: mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true)); If you are using the StaggeredGridLayoutManager , then you can use the setReverseLayout method it provides. You can do it with just xml. the app:reverseLayout="true" do the job! <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="@null" android:orientation="horizontal" app:reverseLayout="true" app:layoutManager="android.support.v7.widget.LinearLayoutManager" /> XML approach using androidx: <androidx.recyclerview.