Posts

Showing posts from January, 2007

Background Blur With CSS

Answer : OCT. 2016 UPDATE Since the -moz-element() property doesn't seem to be widely supported by other browsers except to FF, there's an even easier technique to apply blurring without affecting the contents of the container. The use of pseudoelements is ideal in this case in combination with svg blur filter. Check the demo using pseudo-element (Demo was tested in FF v49, Chrome v53, Opera 40 - IE doesn't seem to support blur either with css or svg filter) The only way (so far) of having a blur effect in the background without js plugins, is the use of -moz-element() property in combination with the svg blur filter. With -moz-element() you can define an element as a background image of another element. Then you apply the svg blur filter. OPTIONAL: You can utilize some jQuery for scrolling if your background is in fixed position. See my demo here I understand it is a quite complicated solution and limited to FF ( element() applies only to Mozilla at

Cmdr Download Code Example

Example: cmder search histroy Press "Ctrl" + "r" and then type your substring to search in your history. Last matching command line will be found, keep using "Ctrl" + "r" to find previous ones. Once you find your searched command just press "Enter" : ( reverse-i-search ) `searched_substring': command_with_searched_substring

Are KiCad's Horizontal 2.54" Pin Header And 90 Degree Pin Headers Equivalent?

Image
Answer : What really matters for the footprint is the pad vs pin spacing. The 3D image is just a frill - it might be nice if the image matched the actual part you have, but it doesn't really matter. (When I started designing PC boards, no-one even dreamed of having a 3D image of the completed board). Based on the source for the KiCad 3d model generator, these pin headers were modeled using a WE 613 0xx 110 21 You can find them in stock at Digikey

Android Studio Layout Table Code Example

Example: table layout android studio < TableLayout android: id = " @+id/table " android: layout_width = " match_parent " android: layout_height = " wrap_content " android: layout_marginVertical = " 30dp " android: layout_marginHorizontal = " 10dp " android: background = " #f1f1f1 " android: collapseColumns = " 1,2 " > < TableRow > < TextView android: layout_width = " wrap_content " android: layout_height = " wrap_content " android: text = " Name " android: textStyle = " bold " android: layout_weight = " 1 " android: gravity = " center " /> < TextView android: layout_width = " wrap_content " a

Check If Port Is Open Or Closed On A Linux Server?

Answer : Solution 1: You can check if a process listens on a TCP or UDP port with netstat -tuplen . To check whether some ports are accessible from the outside (this is probably what you want) you can use a port scanner like Nmap from another system. Running Nmap on the same host you want to check is quite useless for your purpose. Solution 2: Quickest way to test if a TCP port is open (including any hardware firewalls you may have), is to type, from a remote computer (e.g. your desktop): telnet myserver.com 80 Which will try to open a connection to port 80 on that server. If you get a time out or deny, the port is not open :) Solution 3: OK, in summary, you have a server that you can log into. You want to see if something is listening on some port. As root, run: netstat -nlp this will show a listing of processes listening on TCP and UDP ports. You can scan (or grep) it for the process you're interest in,and/or the port numbers you expect to see. If the p

Are Stock Market Events In GTAV Scripted?

Answer : It seems that the assassination missions Lester gives to Franklin, beginning after the first heist, are the most obvious scripted occurances of stock market fluctuation. Most of these affect LCN, but some are companies on BAWSAQ. Before each mission, invest in the target's competitor, ideally with multiple characters. The missions are as follows: Hotel Assassination -- invest in BettaPharmaceuticals . Redwood Cigarette Assassination -- invest in Debonair Cigarettes . Vice Assassination -- invest in Fruit . Bus Assassination -- invest in Vapid after the mission . The stock will fall, but then rise again. Construction Assassination -- invest in Gold Coast . Also, there is a random encounter in which you take a gentleman in a suit to the airport. If you get him there on time, he'll tell you to invest in Tickled on the BAWSAQ market. Doing so is a good idea, as this stock will climb rapidly for some time. Additionally, as noted by other answers, pe

Add Password To Existing Zip File With 7zip

Answer : By nature if you want the file to be encrypted, it needs to be unpacked and repacked, since the whole archive needs to be encrypted with the password. Would it work for you to zip the zip file? Use no/low compression and encrypt the original zip file. Its a lot quicker than repacking the original files.

Codeigniter: How To Include Javascript Files

Answer : You need to use the base_url() to include the javascript file in your VIEW. So, in the view_demo.php file: <script type="text/javascript" src="<?=base_url()?>js/jquery.js" ></script> <script type="text/javascript" src="<?=base_url()?>js/ajax.js" ></script> You will need the URL helper loaded. To load the helper you need to put on your demo.php controller: $this->load->helper('url'); You can also autoload on \config\autoload.php on the helpers array. More info about base_url(): http://www.codeigniter.com/user_guide/helpers/url_helper.html#base_url https://codeigniter.com/user_guide/general/styleguide.html#short-open-tags You wouldn't include JS files within the PHP, they would be output as script tags within the HTML you produce which you may be producing as output from the PHP script. As far as I know, there is no built in CodeIginiter function to include this outpu

Change The URL In The Browser Without Loading The New Page Using JavaScript

Answer : If you want it to work in browsers that don't support history.pushState and history.popState yet, the "old" way is to set the fragment identifier, which won't cause a page reload. The basic idea is to set the window.location.hash property to a value that contains whatever state information you need, then either use the window.onhashchange event, or for older browsers that don't support onhashchange (IE < 8, Firefox < 3.6), periodically check to see if the hash has changed (using setInterval for example) and update the page. You will also need to check the hash value on page load to set up the initial content. If you're using jQuery there's a hashchange plugin that will use whichever method the browser supports. I'm sure there are plugins for other libraries as well. One thing to be careful of is colliding with ids on the page, because the browser will scroll to any element with a matching id. With HTML 5, use the history.p

Append Multiple Items In JavaScript

Answer : You can do it with DocumentFragment. var documentFragment = document.createDocumentFragment(); documentFragment.appendChild(listItem); listItem.appendChild(listItemCheckbox); listItem.appendChild(listItemLabel); listItem.appendChild(editButton); listItem.appendChild(deleteButton); listElement.appendChild(documentFragment); DocumentFragments allow developers to place child elements onto an arbitrary node-like parent, allowing for node-like interactions without a true root node. Doing so allows developers to produce structure without doing so within the visible DOM You can use the append method in JavaScript. This is similar to jQuery's append method but it doesnot support IE and Edge. You can change this code listElement.appendChild(listItem); listItem.appendChild(listItemCheckbox); listItem.appendChild(listItemLabel); listItem.appendChild(editButton); listItem.appendChild(deleteButton); to listElement.append(listItem,listItemCheckbox,listItemLa

Call Custom Confirm Dialog In Ajax.Beginform In MVC3

Answer : I came across this to customize AjaxOptions Confirm text with a value that has not been created yet when Ajax.Beginform is rendered . For example: Confirm="Are you sure you want to create Customer Id" + someValue + "?" Finally a found a solution: The approach is regarding a change in submit button behavior with JQuery to pull the value, run my own Confirm dialog and submit the Ajax form if user confirm. The steps: 1- Remove Confirm from AjaxOptions and avoid set button's type="submit", could be type="button" <div> @using (Ajax.BeginForm("Function", "Controller", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "theForm", InsertionMode = InsertionMode.Replace, LoadingElementId = "iconGif", OnBegin = "OnBegin", OnFailure = "OnFailure", OnSuccess =

Bootstrap 4 Table Foot Code Example

Example: bootstrap 5 tables <!-- BOOTSTRAP V5 --> < table class = " table " > < thead > < 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 </ th > < td > Jacob </ td > < td > Thornton </ td > < td > @fat </ td > </ tr > < tr > < th scope = " row " > 3 </ th > < td

Android On Text Change Listener

Answer : You can add a check to only clear when the text in the field is not empty (i.e when the length is different than 0). field1.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) {} @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(s.length() != 0) field2.setText(""); } }); field2.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) {} @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(s.length() != 0) field1.setText(""); } }); Documentation for TextWatcher here. Also please respect naming con

Bootstrap 5 Datepicker Code Example

Example 1: bootstrap 5 datepicker example < div class = "input-append date" id = "dp3" data - date = "12-02-2012" data - date - format = "dd-mm-yyyy" > < input class = "span2" size = "16" type = "text" value = "12-02-2012" > < span class = "add-on" > < i class = "icon-th" > < / i > < / span > < / div > Example 2: date picker for bootstrap 4 < input class = "datepicker" data - date - format = "mm/dd/yyyy" > Example 3: date picker for bootstrap 4 $ ( '.datepicker' ) . datepicker ( { format : 'mm/dd/yyyy' , startDate : '-3d' } ) ; Example 4: bootstrap datepicker < div class = "container" > < div class = "row" > < div class = 'col-sm-6' > < div class = "form-group" > < d

Android - Resource Linking Failed / Failed Linking References

Image
Answer : Solution 1: Set your compileSdkVersion to 28 and let Android Studio download the needed files. If you already targetting this version, you could try cleaning your project and sync your gradle files. In my case, I made two custom backgrounds which were not recognised. I removed the <?xml version="1.0" encoding="utf-8"?> tag from the top of those two XML resources file. This worked for me, after trying many solutions from the community. Errors with XML files are quite hard to figure out. They even trickle their impact down to Java files.

Javascript Sortby Code Example

Example 1: sort javascript array var points = [ 40 , 100 , 1 , 5 , 25 , 10 ] ; points . sort ( ( a , b ) = > a - b ) Example 2: javascript orderby var items = [ { name : 'Edward' , value : 21 } , { name : 'Sharpe' , value : 37 } , { name : 'And' , value : 45 } , { name : 'The' , value : - 12 } , { name : 'Magnetic' , value : 13 } , { name : 'Zeros' , value : 37 } ] ; // sort by value items . sort ( function ( a , b ) { return a . value - b . value ; } ) ; // sort by name items . sort ( function ( a , b ) { var nameA = a . name . toUpperCase ( ) ; // ignore upper and lowercase var nameB = b . name . toUpperCase ( ) ; // ignore upper and lowercase if ( nameA < nameB ) { return - 1 ; } if ( nameA > nameB ) { return 1 ; } // names must be equal return 0 ; } ) ; Example 3: javascript sort var names = [

Chart.js 2.0 Doughnut Tooltip Percentages

Answer : Update: The below answer shows a percentage based on total data but @William Surya Permana has an excellent answer that updates based on the shown data https://stackoverflow.com/a/49717859/2737978 In options you can pass in a tooltips object (more can be read at the chartjs docs) A field of tooltips , to get the result you want, is a callbacks object with a label field. label will be a function that takes in the tooltip item which you have hovered over and the data which makes up your graph. Just return a string, that you want to go in the tooltip, from this function. Here is an example of what this can look like tooltips: { callbacks: { label: function(tooltipItem, data) { //get the concerned dataset var dataset = data.datasets[tooltipItem.datasetIndex]; //calculate the total of this data set var total = dataset.data.reduce(function(previousValue, currentValue, currentIndex, array) { return previousValue + currentValue

Std String Replace Substring Code Example

Example: c++ replace substrings using namespace std ; string ReplaceAllSubstringOccurrences ( string sAll , string sStringToRemove , string sStringToInsert ) { int iLength = sStringToRemove . length ( ) ; size_t index = 0 ; while ( true ) { /* Locate the substring to replace. */ index = sAll . find ( sStringToRemove , index ) ; if ( index == std :: string :: npos ) break ; /* Make the replacement. */ sAll . replace ( index , iLength , sStringToInsert ) ; /* Advance index forward so the next iteration doesn't pick it up as well. */ index += iLength ; } return sAll ; } // EXAMPLE: in usage string sInitialString = "Replace this, and also this, don't forget this too" ; string sFinalString = ReplaceAllSubstringOccurrences ( sInitialString , "this" , "{new word/phrase}" ) ; cout << "[sInitialString->" << sInit

Bootstrap Logo Code Example

Example 1: bootstrap navbar Navbar Home (current) Features Pricing Disabled Example 2: bootstrap4 navbar Navbar Home (current) Features Pricing Disabled Example 3: navbar bootstrap 4 with dropdown Navbar Home (current) Link Dropdown Action Another action Something else here Disabled Search Example 4: bootstrap 4 navbar with logo and nav on right Navbar Home (current) Features Pricing Disabled Example 5: navbar in bootstrap4 Collapsed content Toggleab

Angular Typescript Interface Default Value

Answer : If you don't want to create an object and assign default values every time, use a class with default values for its properties instead. If you don't specify the values, defaults values will be used according to your property types. export class MapMarker { longitude: number = 0; latitude: number = 0; popupText: string = ''; } Then you can simply create an instance of your class and every field will be correctly initialized: mapMarker: MapMarker = new MapMarker(); If you want to keep your interface, just implement it in the class: export interface IMapMarker { longitude: number; latitude: number; popupText: string; } export class MapMarker implements IMapMarker { longitude: number = 0; latitude: number = 0; popupText: string = ''; } If some of your properties are optional, use the optional operator for them: export interface IMapMarker { longitude?: number; latitude?: number; popupText?: s