Posts

Showing posts from September, 2020

Can I Make A CSS Grid With Dynamic Number Of Rows Or Columns?

Answer : Okay, after reading the MDN reference, I found the answer! The key to dynamic rows (or columns) is the repeat property. const COLORS = [ '#FE9', '#9AF', '#F9A', "#AFA", "#FA7" ]; function addItem(container, template) { let color = COLORS[_.random(COLORS.length - 1)]; let num = _.random(10000); container.append(Mustache.render(template, { color, num })); } $(() => { const tmpl = $('#item_template').html() const container = $('#app'); for(let i=0; i<5; i++) { addItem(container, tmpl); } $('#add_el').click(() => { addItem(container, tmpl); }) container.on('click', '.del_el', (e) => { $(e.target).closest('.item').remove(); }); }); .container { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(auto-fill, 120px); grid-row-gap: .5em; grid-column-gap: 1em; } .contain

Apple - AutoHotkey Equivalent For OS X?

Image
Answer : Check out Hammerspoon. It seems to be very fully featured and — like AutoHotkey — offers a programmatic way to do all sorts of OSX automation, in addition to key binding/remapping. (It takes a plugin based approach. Karabiner, mentioned in an answer above, can be used as a plugin too allowing its functionality to be enhanced in all sorts of ways.) http://www.hammerspoon.org/ I recommend Keyboard Maestro which lets you set up macros with various actions that can be triggered with keyboard shortcuts or other triggers. I use Karabiner. It is a bit of a pain to customize (it uses XML), but it is just as powerful as AHK. It can also move the mouse.

CMake Custom Command Copy Multiple Files

Answer : I did it with a loop # create a list of files to copy set( THIRD_PARTY_DLLS C:/DLLFOLDER/my_dll_1.dll C:/DLLFOLDER/my_dll_2.dll ) # do the copying foreach( file_i ${THIRD_PARTY_DLLS}) add_custom_command( TARGET ${VIEWER_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${file_i} "C:/TargetDirectory" ) endforeach( file_i ) Copying multiple files is available from CMake 3.5 cmake -E copy <file>... <destination> "cmake -E copy" support for multiple files Command-Line Tool Mode A relatively simple workaround would be to use ${CMAKE_COMMAND} -E tar to bundle the sources, move the tarball and extract it in the destination directory. This could be more trouble than it's worth if your sources are scattered across many different directories, since extracting would retain the original directory structure (unlike using cp ). If all the files are in one directory however, you could achieve the copy in jus

An Example Of An Exists-sentence Such That The Sentence Is True On An Infinite Model M, Yet On Every Submodel, The Sentence Is False

Answer : As Noah and Eric pointed out, the statement of the proplem is missing the word "proper" (the sentence should be false only on the proper substructures of M M M , since M M M is alwaays a substructure of itself). And the problem can be solved vacuously by considering a structure M M M with no proper substructures. The solution as you described it makes no sense. Here's an example which does have proper substructures and which I believe is similar in spirit to the intention of the proposed solution (but simpler). Consider the language { P , f } \{P,f\} { P , f } , where P P P is a unary relation symbol and f f f is a unary function symbol. Let M = N M = \mathbb{N} M = N , where P M P^M P M holds only of 0 0 0 and f M f^M f M is the successor function f M ( n ) = n + 1 f^M(n) = n+1 f M ( n ) = n + 1 . The substructures of M M M are of the form { k , k + 1 , k + 2 , …   } \{k,k+1,k+2,\dots\} { k , k + 1 , k + 2 , … } for any k k k . Consider the sent

Bootstrap 4 Form Input With Icon For Validation

Answer : Bootstrap 4 doesn't include icons (glyphicons are gone), and there are now just 2 validation states ( is-valid and is-invalid ) that control display of the valid-feedback and invalid-feedback text. With a little extra CSS, you can position an icon inside the input (to the right), and control its' display using is-valid or is-invalid on the form-control input. Use a font lib like fontawesome for the icons. I created a new feedback-icon class that you can add to the valid/invalid-feedback . .valid-feedback.feedback-icon, .invalid-feedback.feedback-icon { position: absolute; width: auto; bottom: 10px; right: 10px; margin-top: 0; } HTML <div class="form-group position-relative"> <label for="input2">Valid with icon</label> <input type="text" class="form-control is-valid" id="input2"> <div class="valid-feedback feedback-icon">

Are Class Names In CSS Selectors Case Sensitive?

Answer : CSS selectors are generally case-insensitive; this includes class and ID selectors. But HTML class names are case-sensitive (see the attribute definition), and that's causing a mismatch in your second example. This has not changed in HTML5. 1 This is because the case-sensitivity of selectors is dependent on what the document language says: All Selectors syntax is case-insensitive within the ASCII range (i.e. [a-z] and [A-Z] are equivalent), except for parts that are not under the control of Selectors. The case sensitivity of document language element names, attribute names, and attribute values in selectors depends on the document language. So, given an HTML element with a Selfcatering class but without a SelfCatering class, the selectors .Selfcatering and [class~="Selfcatering"] will match it, while the selectors .SelfCatering and [class~="SelfCatering"] would not. 2 If the document type defined class names as case-insensitive,

Anaconda Python Spyder Download Code Example

Example: download spyder without anaconda 1 . python -m pip install pyqt5 2 . python -m pip install spyder 3 . python -m pip install PyQtWebEngine 4 . spyder3 ( to launch spyder )

Bootstrap Table Template With Css Code Example

Example 1: table bootstrap with scrool < div style = " height : 600 px ; overflow : scroll ; " > <!-- change height to increase the number of visible row --> < table > </ table > </ div > Example 2: table class in bootstrap < table class = " table " > < thead class = " thead-dark " > < tr > < th scope = " col " > # </ th > < th scope = " col " > First </ th > < th scope = " col " > Last </ th > < th scope = " col " > Handle </ th > </ tr > </ thead > < tbody > < tr > < th scope = " row " > 1 </ th > < td > Mark </ td > < td > Otto </ td > < td > @mdo </ td > </ tr > < tr > < th scope = " row " > 2
Note This plugin is part of the community.kubernetes collection (version 1.1.1). To install it use: ansible-galaxy collection install community.kubernetes . To use it in a playbook, specify: community.kubernetes.helm . New in version 0.11.0: of community.kubernetes Synopsis Requirements Parameters Examples Return Values Synopsis Install, upgrade, delete packages with the Helm package manager. Note This module has a corresponding action plugin . Requirements The below requirements are needed on the host that executes this module. helm ( https://github.com/helm/helm/releases) yaml ( https://pypi.org/project/PyYAML/) Parameters Parameter Choices/Defaults Comments atomic boolean Choices: no ← yes If set, the installation process deletes the installation on failure. binary_path path The path of a helm binary to use. chart_ref path chart_reference on chart repository. path to a packaged chart. path to an un

Check String Contains Substring Javascript Code Example

Example 1: js string contais const string = "foo" ; const substring = "oo" ; console . log ( string . includes ( substring ) ) ; Example 2: js check if string contains character if ( your_string . indexOf ( 'hello' ) > - 1 ) { alert ( "hello found inside your_string" ) ; }

Single Source Shortest Path Dijkstra Algorithm In C Code Example

Example: dijkstra algorithm c++ # include <bits/stdc++.h> using namespace std ; int main ( ) { int n = 9 ; int mat [ 9 ] [ 9 ] = { { 100 , 4 , 100 , 100 , 100 , 100 , 100 , 8 , 100 } , { 4 , 100 , 8 , 100 , 100 , 100 , 100 , 11 , 100 } , { 100 , 8 , 100 , 7 , 100 , 4 , 100 , 100 , 2 } , { 100 , 100 , 7 , 100 , 9 , 14 , 100 , 100 , 100 } , { 100 , 100 , 100 , 9 , 100 , 100 , 100 , 100 , 100 } , { 100 , 100 , 4 , 14 , 10 , 100 , 2 , 100 , 100 } , { 100 , 100 , 100 , 100 , 100 , 2 , 100 , 1 , 6 } , { 8 , 11 , 100 , 100 , 100 , 100 , 1 , 100 , 7 } , { 100 , 100 , 2 , 100 , 100 , 100 , 6 , 7 , 100 } } ; int src = 0 ; int count = 1 ; int path [ n ] ; for ( int i = 0 ; i < n ; i ++ ) path [ i ] = mat [ src ] [ i ] ; int visited [ n ] =

Android: Styling Overflow Menu In Action Bar

Answer : I did it this way: <style name="Theme.yourapp" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="android:actionBarWidgetTheme">@style/Theme.yourapp.Widget</item> </style> <style name="Theme.yourapp.Widget" parent="@style/Theme.AppCompat"> <item name="android:textColor">@android:color/black</item> </style> For simplicity, the android: namespace pertains to anything built into the OS while anything without android: as the namespace would pertain to your application (and the libraries you are using). Most, if not all, support libraries for the ActionBar will try to use the native ActionBar implementation and therefor use the android: namespace attributes in your styles. When the native ActionBar is not available it would use the libraries implementation and the non- android: namespaced attributes. This is why you must specify every attribute w

Arraylist Api In Java Code Example

Example 1: java arraylist import java . util . List ; //list abstract class import java . util . ArrayList ; //arraylist class //Object Lists List l = new ArrayList ( ) ; ArrayList a = new ArrayList ( ) ; //Specialized List List < String > l = new ArrayList < String > ( ) ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; //only reference data types allowed in brackets <> //Initial Capacity List < Double > l = new ArrayList < Double > ( 5 ) ; //list will start with a capacity of 5 //saves allocation times Example 2: arraylist java methds import java . util . ArrayList ; ArrayList < Integer > myList = new ArrayList < Integer > ( ) ; myList . add ( 0 ) ; myList . remove ( 0 ) ; //Remove at index 0 myList . size ( ) ; myList . get ( 0 ) ; //Return element at index 0

Bash Associative Array Sorting By Value

Answer : You can easily sort your output, in descending numerical order of the 3rd field: for k in "${!authors[@]}" do echo $k ' - ' ${authors["$k"]} done | sort -rn -k3 See sort(1) for more about the sort command. This just sorts output lines; I don't know of any way to sort an array directly in bash. I also can't see how the above can give you names ("Pushkin" et al.) as array keys. In bash, array keys are always integers. Alternatively you can sort the indexes and use the sorted list of indexes to loop through the array: authors_indexes=( ${!authors[@]} ) IFS=$'\n' authors_sorted=( $(echo -e "${authors_indexes[@]/%/\n}" | sed -r -e 's/^ *//' -e '/^$/d' | sort) ) for k in "${authors_sorted[@]}"; do echo $k ' - ' ${authors["$k"]} done Extending the answer from @AndrewSchulman, using -rn as a global sort option reverses all columns. In this example, author

Can't Drop Foreign Key In MySQL

Answer : Please run an SHOW CREATE TABLE course; to make sure instructorID is the name of foreign key constraint . Additional: The error means MySQL searches for a foreign key constraint named "InstructorID" but there is no constraint with such name, maybe this is your column name, but you have to use the constraint name to delete foreign keys. After you run SHOW CREATE table course; you should find the fk symbol which is commonly like the one bellow: (course_ibfk_1) it may differ according to your mysql version you are using then drop the foreign key using the fk symbol as follow : alter table course drop foreign key course_ibfk_1; You need to delete the 'foreign key constraint' and the 'key'. Alter Table <table name> drop foreign key <constraint_name> Alter table <table name> drop key <column name>

Add Extra Fields Using JMS Serializer Bundle

Answer : I've found the solution by myself, to add a custom field after the serialization has been done we've to create a listener class like this: <?php namespace Acme\DemoBundle\Listener; use JMS\DiExtraBundle\Annotation\Service; use JMS\DiExtraBundle\Annotation\Tag; use JMS\DiExtraBundle\Annotation\Inject; use JMS\DiExtraBundle\Annotation\InjectParams; use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Acme\DemoBundle\Entity\Team; use JMS\Serializer\Handler\SubscribingHandlerInterface; use JMS\Serializer\EventDispatcher\EventSubscriberInterface; use JMS\Serializer\EventDispatcher\PreSerializeEvent; use JMS\Serializer\EventDispatcher\ObjectEvent; use JMS\Serializer\GraphNavigator; use JMS\Serializer\JsonSerializationVisitor; /** * Add data after serialization * * @Service("acme.listener.serializationlistener") * @Tag("jms_serializer.event_subscriber") */ class SerializationListener implements EventSubscriberInterface { /**

Bootstrap Range Slider Min Max Code Example

Example 1: price range slider bootstrap 4 < input type = "range" name = "range" step = "50000" min = "100000" max = "1000000" value = "" onchange = "rangePrimary.value=value" > < input type = "text" id = "rangePrimary" / > Example 2: bootstrap 3 min max price range slider < ! doctype html > < html lang = "en" > < head > < meta charset = "utf-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1" > < title > jQuery UI Slider - Range slider < / title > < link rel = "stylesheet" href = "//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" > < link rel = "stylesheet" href = "/resources/demos/style.css" > < script src = "https://code.jquery.com/jquery-1.12.4.js" > < / script