Posts

Showing posts from December, 2014

Compile Php In On Line Code Example

Example: php online editor Try this sites to write php code online : http : //www.writephponline.com/ http : //sandbox.onlinephpfunctions.com/ https : //paiza.io/en/projects/new http : //phptester.net/ https : //www.tutorialspoint.com/execute_php_online.php https : //rextester.com/l/php_online_compiler http : //phpfiddle.org/ https : //repl.it/languages/php_cli https : //www.jdoodle.com/php-online-editor/

Active Admin Action Item/member Action

Answer : This can be done with the following: ActiveAdmin.register Post do index do column :name actions defaults: true do |post| link_to 'Archive', archive_admin_post_path(post) end end end Note that using defaults: true will append your custom actions to active admin default actions. For the friend who landed the page, In order to append more than 1 link Do Something Like: actions default: true do |model| [ link_to('Option 1', "#"), ' ', link_to('Option 2', "#") ].reduce(:+).html_safe end Found an answer here. You can do it using the below code with the code from the question (removing the action item block) index do ... actions do |subscription| link_to('Approve', approve_admin_subscription_path(subscription)) end ... end But I think there is a way to do it by appending an action to the default actions (so if you kn

Br Full Form In Html Code Example

Example: html The HTML <br> tag is used to make a break in lines. it could be used in a list command , like so : <p2>This is my list. <br> The tag makes a break <br> Very helpful. <br><p2> The tag is very helpful , and it makes things look much cleaner. To use it , just put it at the end , it is a very simple-to-use tag.

Aggregate Unique Values From Multiple Columns With Pandas GroupBy

Answer : Use groupby and agg , and aggregate only unique values by calling Series.unique : df.astype(str).groupby('prop1').agg(lambda x: ','.join(x.unique())) prop2 prop3 prop4 prop1 K20 12,1,66 travis,leo 10.0,4.0 L30 3,54,11,10 bob,john 11.2,10.0 df.astype(str).groupby('prop1', sort=False).agg(lambda x: ','.join(x.unique())) prop2 prop3 prop4 prop1 L30 3,54,11,10 bob,john 11.2,10.0 K20 12,1,66 travis,leo 10.0,4.0 If handling NaNs is important, call fillna in advance: import re df.fillna('').astype(str).groupby('prop1').agg( lambda x: re.sub(',+', ',', ','.join(x.unique())) ) prop2 prop3 prop4 prop1 K20 12,1,66 travis,leo 10.0,4.0 L30 3,54,11,10 bob,john 11.2,10.0

Alter Table Add Column Query 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 ;

A Tag Open In New Tab Code Example

Example 1: open link in a new tab hmtl < a href = " https://insert.url " target = " _blank " > The Website Linked </ a > Example 2: how to make a link in html that opens in a new tab add attribute : target = "_blank" Example 3: open new tab href < a target = " _blank " rel = " noopener noreferrer " href = " http://your_url_here.html " > Link </ a > Example 4: a tag open in new tab < a href = " # " target = " _blank " rel = " noopener noreferrer " > Link </ a >

Bootstrap Timeline Graph Code Example

Example: bootstrap timeline To get the bootstrat timeline go to https://freefrontend.com/bootstrap-timelines/

"Build Failed" On Database First Scaffold-DbContext

Answer : Two most important tips: [1] - Make sure that your project builds completely before you run a new scaffold command. Otherwise... You'll start writing a line of code. You'll realize a required DB column is missing from your model. You'll go to try to scaffold it. Twenty minutes later you'll realize the reason your build (and scaffold command) is failing is because you literally have a half written line of code. Oops! [2] - Check into source control or make a copy: Allows you to easily verify what changed. Allows rollback if needed. You can get some very annoying 'chicken and egg' problems if you get unlucky or make a mistake. Other problems: If you have multiple DLLs make sure you aren't generating into the wrong project . A 'Build failed' message can occur for many reasons, but the dumbest would be if you don't have EFCore installed in the project you're scaffolding into. In the package manager console there is

Csharp Random Name Picker Code Example

Example: generate random name c# private void RandName ( ) { string [ ] maleNames = new string [ 1000 ] { "aaron" , "abdul" , "abe" , "abel" , "abraham" , "adam" , "adan" , "adolfo" , "adolph" , "adrian" } ; string [ ] femaleNames = new string [ 1000 ] { "abby" , "abigail" , "adele" , "adrian" } ; string [ ] lastNames = new string [ 1000 ] { "abbott" , "acosta" , "adams" , "adkins" , "aguilar" } ; Random rand = new Random ( DateTime . Now . Second ) ; if ( rand . Next ( 1 , 2 ) == 1 ) { FirstName = maleNames [ rand . Next ( 0 , maleNames . Length - 1 ) ] ; } else { FirstName = femaleNames [ rand . Next ( 0 , femaleNames . Length - 1 ) ] ; } }

Css Div Side By Side Code Example

Example 1: how to align two divs side by side .wrapper { display: flex; flex-wrap: wrap; } .wrapper>div { flex: 1 1 150px; height: 500px; } Example 2: div side by side .float-container { border: 3px solid #fff; padding: 20px; } .float-child { width: 50%; float: left; padding: 20px; border: 2px solid red; } < div class = " float-container " > < div class = " float-child " > < div class = " green " > Float Column 1 </ div > </ div > < div class = " float-child " > < div class = " blue " > Float Column 2 </ div > </ div > </ div > Example 3: place div side by side < div style = " width : 100 % ; display : table ; " > < div style = " display : table-row " > < div style = " width : 600 px ; display : table-cell ; " > Left </ div >

Android Transparent Status Bar And Actionbar

Image
Answer : I'm developing an app that needs to look similar in all devices with >= API14 when it comes to actionbar and statusbar customization. I've finally found a solution and since it took a bit of my time I'll share it to save some of yours. We start by using an appcompat-21 dependency. Transparent Actionbar : values/styles.xml : <style name="AppTheme" parent="Theme.AppCompat.Light"> ... </style> <style name="AppTheme.ActionBar.Transparent" parent="AppTheme"> <item name="android:windowContentOverlay">@null</item> <item name="windowActionBarOverlay">true</item> <item name="colorPrimary">@android:color/transparent</item> </style> <style name="AppTheme.ActionBar" parent="AppTheme"> <item name="windowActionBarOverlay">false</item> <item name="colorPrimary"

How To Find Array Length In Python Code Example

Example 1: python get array length # To get the length of a Python array , use 'len()' a = arr . array ( ‘d’ , [ 1.1 , 2.1 , 3.1 ] ) len ( a ) # Output : 3 Example 2: find array length in python a = arr . array ( 'd' , [ 1.1 , 2.1 , 3.1 ] ) len ( a )

38 C To F Code Example

Example: 14 f to c 14 °F = - 10 °C

Css Trick Grid Code Example

Example 1: css grid .item-a { grid-area: header; } .item-b { grid-area: main; } .item-c { grid-area: sidebar; } .item-d { grid-area: footer; } .container { display: grid; grid-template-columns: 50px 50px 50px 50px; grid-template-rows: auto; grid-template-areas: "header header header header" "main main . sidebar" "footer footer footer footer"; } Example 2: choose grid position html /* grid-column: < start > / < end > ; */ /* grid-row: < start > / span < length > ; */ /* i.e */ grid-column: 3 / span 2; grid-row: 2 / 4; grid-row: 4; Example 3: display grid .container { display: grid | inline-grid; }

Convertio Pdf To Word Code Example

Example: pdf to word Just use Adobe Online converter it's free for one time and for more than 1 you may have to sign in , just use a temp mail like "moakt mail" or "temp mail" and u r good to go. Link : https : //www.adobe.com/in/acrobat/online/word-to-pdf.html temp mail : https : //temp-mail.org/

Acid Properties In Dbms Geeksforgeeks Code Example

Example: acid properties in dbms Atomicity The entire transaction take place at once or doesn't happen at all. Consistency Database must be consistent before and after the transaction. Isolation Multiple transactions occur independently without interference. Durability The changes of the successful transaction occurs even if the system failure occur.

Adb Pull Multiple Files

Answer : You can use xargs and the result of the adb shell ls command which accepts wildcards. This allows you to copy multiple files. Annoyingly the output of the adb shell ls command includes line-feed control characters that you can remove using tr -d '\r' . Examples: # Using a relative path adb shell 'ls sdcard/gps*.trace' | tr -d '\r' | xargs -n1 adb pull # Using an absolute path adb shell 'ls /sdcard/*.txt' | tr -d '\r' | sed -e 's/^\///' | xargs -n1 adb pull adb pull can receive a directory name instead of at file and it will pull the directory with all files in it. Pull all your gps traces in /sdcard/gpsTraces adb pull /sdcard/gpsTraces/ . Example of adb pull and adb push of recursive directories: C:\Test>adb pull /data/misc/test/ . pull: building file list... pull: /data/misc/test/test1/test2/test.3 -> ./test1/test2/test.3 pull: /data/misc/test/test1/test2/test.2 -> ./test1/test2/test.2 pull: /data/

Conda List Packages Code Example

Example 1: list conda environments conda info --envs conda env list Example 2: conda list environments conda info --envs Example 3: anaconda virtual environment LIST conda env list Example 4: conda list available package versions # Basic syntax: conda search package_name Example 5: how to use pip install conda environment Open Anaconda Navigator Select Environments in the left hand pane below home Just to the right of where you selected and below the "search environments" bar, you should see base(root). Click on it A triangle pointing right should appear, click on it an select "open terminal" Use the regular pip install command here. There is no need to point to an environment/ path

Calling A Function In Javascript With Settime Code Example

Example: javascript run something after x seconds setTimeout ( function ( ) { location . reload ( ) ; } , 3000 ) ; //run this after 3 seconds

35 Minute Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

Why C And C++ Are Platform Dependent Code Example

Example: is c and c++ platform independent In C , C ++ the compiled code ( compiler given code ) is machine language code which is understandable only by the cureent operating system . Hence this compiled code can not be executed in another platform . Due to this reason these languages are considered as platform dependent programming languages .

Css Text Three Dots Code Example

Example 1: overflow dottet .cut-text { text-overflow : ellipsis ; overflow : hidden ; white-space : nowrap ; } Example 2: overflow dots css .overflow-information { overflow : hidden ; display : inline-block ; text-overflow : ellipsis ; white-space : nowrap ; width : 150 px ; //change based on when you want the dots to appear } Example 3: three dots in css span { display : inline-block ; width : 180 px ; white-space : nowrap ; overflow : hidden !important ; text-overflow : ellipsis ; }

Style Disabled Button Css Code Example

Example 1: style disabled button button :disabled , button [ disabled ] { border : 1 px solid #999999 ; background-color : #cccccc ; color : #666666 ; } Example 2: css for disabled button /* CSS Selectors for CSS2 and CSS3 both */ button :disabled , button [ disabled ] { border : 1 px solid #999999 ; background-color : #cccccc ; color : #666666 ; }

Bulk Crop Images From CMD/PowerShell

Answer : ImageMagick is a light-weight tool that can be used for this. Here is an example that croppes all jpg images in a directory and puts the results in a new folder: cd path/to/dir/ mogrify -crop +100+10 -quality 100 -path ../cropped *.jpg Here, 100 pixels from the left border and 10 pixels from the top are removed. See here for more information on how to use crop. Have you tried XnCovert? XnConvert is free cross-platform batch image processor, allowing you to combine over 80 actions. Compatible with 500 formats. It uses the batch processing module of XnViewMP and it is freeware and you can donate them if you find it useful. https://www.xnview.com/en/xnconvert/

Latex Double Space Lines Code Example

Example 1: latext double space \usepackage { setspace } \doublespacing Example 2: spacing lines latex \usepackage { setspace } \doublespacing

Console.log In Dart Language

Answer : Simple: print('This will be logged to the console in the browser.'); A basic top-level print function is always available in all implementations of Dart (browser, VM, etc.). Because Dart has string interpolation, it's easy to use that to print useful stuff too: var a = 123; var b = new Point(2, 3); print('a is $a, b is ${b.x}, ${b.y}'); Also, dart:html allows use of window.console object. import 'dart:html'; void main() { window.console.debug("debug message"); window.console.info("info message"); window.console.error("error message"); } It’s easy! Just import the logging package: import 'package:logging/logging.dart'; Create a logger object: final _logger = Logger('YourClassName'); Then in your code when you need to log something: _logger.info('Request received!'); If you catch an exception you can log it and the stacktrace as well. _logger.severe('Oops, an error occurred', er

Can Anyone Give A Real Life Example Of Supervised Learning And Unsupervised Learning?

Answer : Supervised learning: You get a bunch of photos with information about what is on them and then you train a model to recognize new photos. You have a bunch of molecules and information about which are drugs and you train a model to answer whether a new molecule is also a drug. Unsupervised learning: You have a bunch of photos of 6 people but without information about who is on which one and you want to divide this dataset into 6 piles, each with the photos of one individual. You have molecules, part of them are drugs and part are not but you do not know which are which and you want the algorithm to discover the drugs. Supervised Learning: is like learning with a teacher training dataset is like a teacher the training dataset is used to train the machine Example: Classification: Machine is trained to classify something into some class. classifying whether a patient has disease or not classifying whether an email is spam or no

How Do I Get The Mouse Position Coordinates In Unity Code Example

Example: unity get mouse position Vector3 worldPosition = Camera . main . ScreenToWorldPoint ( Input . mousePosition ) ;