Posts

Showing posts from June, 2005

CreateNode Js Code Example

Example 1: create element javascript with id var btn = document . createElement ( 'div' ) ; btn . setAttribute ( "id" , "div1" ) ; Example 2: document create element document . body . onload = addElement ; function addElement ( ) { // create a new div element var newDiv = document . createElement ( "div" ) ; // and give it some content var newContent = document . createTextNode ( "Hi there and greetings!" ) ; // add the text node to the newly created div newDiv . appendChild ( newContent ) ; // add the newly created element and its content into the DOM var currentDiv = document . getElementById ( "div1" ) ; document . body . insertBefore ( newDiv , currentDiv ) ; }

CSS Even Odd For Every Other Odd Div In Class

Answer : :nth-child(4n) gives us 0, 4, 8, etc. Since you want 1, 5, 9, you should try :nth-child(4n + 1) What you want to do is apply the css to every fourth row, so you want to do: .myClass:nth-child(4n+1)

Brew Uninstall Node Code Example

Example 1: brew uninstall node brew uninstall node; which node; sudo rm -rf /usr/local/bin/node; sudo rm -rf /usr/local/lib/node_modules/npm/; brew doctor; brew cleanup --prune-prefix; Example 2: uninstall node js from mac sudo rm -rf ~/.npm ~/.nvm ~/node_modules ~/.node-gyp ~/.npmrc ~/.node_repl_history sudo rm -rf /usr/local/bin/npm /usr/local/bin/node-debug /usr/local/bin/node /usr/local/bin/node-gyp sudo rm -rf /usr/local/share/man/man1/node* /usr/local/share/man/man1/npm* sudo rm -rf /usr/local/include/node /usr/local/include/node_modules sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /usr/local/lib/dtrace/node.d sudo rm -rf /opt/local/include/node /opt/local/bin/node /opt/local/lib/node sudo rm -rf /usr/local/share/doc/node sudo rm -rf /usr/local/share/systemtap/tapset/node.stp brew uninstall node brew doctor brew cleanup --prune-prefix

Rgba Light Green Code Example

Example: rgba green color rgb ( 0 , 128 , 0 ) /*green*/ Hex #008000

Code Block In Discord Code Example

Example 1: format code discord ```my language my code ``` Example 2: css discord color guide Default : # 839496 ``` NoKeyWordsHere ``` Quote : # 586e75 ```brainfuck NoKeyWordsHere ``` Solarized Green : # 859900 ```CSS NoKeyWordsHere ``` Solarized Cyan : # 2 aa198 ```yaml NoKeyWordsHere ``` Solarized Blue : # 268 bd2 ```md NoKeyWordsHere ``` Solarized Yellow : #b58900 ```fix NoKeyWordsHere ``` Solarized Orange : #cb4b16 ```glsl NoKeyWordsHere ``` Solarized Red : #dc322f ```diff - NoKeyWordsHere ``` Example 3: css discord color guide And here is the escaped Default : # 839496 ``` This is a for statement ``` Quote : # 586e75 ```bash # This is a for statement ``` Solarized Green : # 859900 ```diff + This is a for statement ``` //Second Way to do it ```diff ! This is a for statement ``` Solarized Cyan : # 2 aa198 ```cs "This is a for statement" ``` ```cs 'This is a for statement' ``` Solarized Blue : # 268 bd2 ```ini [ This

Wordpress - Count How Many Posts In Category

Answer : If I remember right count of posts in category is stored persistently in category object. So use get_category() or variation of it and fetch the number out of object. Example code (not tested): $category = get_category($id); $count = $category->category_count; if( $count > $something ) { // stuff }

Text Decoration Css Underline Thickness Code Example

Example: how to change the underline thickness in css text-decoration-thickness : 3 px ; text-decoration-thickness : 5 % ;

Composer Update Single Package With Dependencies Code Example

Example 1: update particular package composer composer update doctrine/doctrine-fixtures-bundle Example 2: composer update single package composer require phpmailer/phpmailer

Add Background Image In Python Tkinter Code Example

Example 1: ad background image with tkinter app = Tk ( ) app . title ( "Welcome" ) image2 = Image . open ( 'C : \\Users\\adminp\\Desktop\\titlepage\\front . gif' ) image1 = ImageTk . PhotoImage ( image2 ) w = image1 . width ( ) h = image1 . height ( ) app . geometry ( ' % dx % d + 0 + 0 ' % ( w , h ) ) #app.configure(background='C:\\Usfront.png') #app.configure(background = image1) labelText = StringVar ( ) labelText . set ( "Welcome !!!!" ) #labelText.fontsize('10') label1 = Label ( app , image = image1 , textvariable = labelText , font = ( "Times New Roman" , 24 ) , justify = CENTER , height = 4 , fg = "blue" ) label1 . pack ( ) app . mainloop ( ) Example 2: tkinter background image python 3 You need to apply the grid method to the label that contains the image , not the image object : bg_image = PhotoImage ( file = "pic.gif" ) x = Label ( image = bg_im

8cm In Inches Code Example

Example: cm to inches const cm = 1; console.log(`cm:${cm} = in:${cmToIn(cm)}`); function cmToIn(cm){ var in = cm/2.54; return in; }

Android Studio Error Running App No Target Device Found Code Example

Example: no target device found android studio Choose "Run" then "Edit Configurations". In the "General" tab, check the "Deployment Target Options" section. In my case, the target was already set to "USB Device" and the checkbox "Use same device for future launches" was checked. I had to change the target to "Show Device Chooser Dialog" and I unchecked the check box. Then my device appeared in the list. If your device still doesn't appear, then you have to enable USB-Debugging in the smartphone settings again.

Alternative To Google Finance Api

Answer : Updating answer a bit 1. Try Twelve Data API For beginners try to run the following query with a JSON response: https://api.twelvedata.com/time_series?symbol=AAPL&interval=1min&apikey=demo&source=docs NO more real time Alpha Vantage API For beginners you can try to get a JSON output from query such as https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=demo DON'T Try Yahoo Finance API (it is DEPRECATED or UNAVAILABLE NOW). Here is a link to previous Yahoo Finance API discussion on StackOverflow. Here's an alternative link to Yahoo Finance API posted on Google Code. For beginners, you can generate a CSV with a simple API call: http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=sb2b3jk (This will generate and save a CSV for AAPL, GOOG, and MSFT) Note that you must append the format to the query string ( f=.. ). For an overview of all of the formats see this page. For more examples, visit this p

Android AlarmManager: Is There A Way To Cancell ALL The Alarms Set?

Answer : if you are canceling previous alarms then in PendingIntent your flag should be PendingIntent.FLAG_CANCEL_CURRENT . It will prevent generating a new PendingIntent if it is already created. And make sure that before setting in alarm just cancel that same PendingIntent and after that set your alarm. You should try like this: AlarmManager 2AlarmsInWeekAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pendingIntent = PendingIntent.getService/getActivity(context, int, intent, PendingIntent.FLAG_CANCEL_CURRENT); 2AlarmsInWeekAlarmManager.cancel(pendingIntent); and then you may use set or setRepeating method. In your case it should be 2AlarmsInWeekAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, "timeInMillis", "repetitionTimeInMillis", pendingintent); This guarantees that before setting an alarm will cancel all previously alarm with the same PendingIntent . Hope you got this! I think you could get an

An Example Of Encrypting An Xml File In Java Using Bouncy Castle

Answer : What type of encryption do you want to perform? Password-based (PBE), symmetric, asymmetric? Its all in how you configure the Cipher. You shouldn't have to use any BouncyCastle specific APIs, just the algorithms it provides. Here is an example that uses the BouncyCastle PBE cipher to encrypt a String: import java.security.SecureRandom; import java.security.Security; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import org.bouncycastle.jce.provider.BouncyCastleProvider; public class PBE { private static final String salt = "A long, but constant phrase that will be used each time as the salt."; private static final int iterations = 2000; private static final int keyLength = 256; private static final SecureRandom random = new SecureRandom(); public static void main(String [] args) throws Exception {

Polymorphism In C++ Geeksforgeeks Code Example

Example: polymorphism-program.cpp # include <iostream> using namespace std ; class Person { public : virtual void introduce ( ) { cout << "hey from person" << endl ; } } ; class Student : public Person { public : void introduce ( ) { cout << "hey from student" << endl ; } } ; class Farmer : public Person { public : void introduce ( ) { cout << "hey from Farmer" << endl ; } } ; void whosThis ( Person & p ) { p . introduce ( ) ; } int main ( ) { Farmer anil ; Student alex ; whosThis ( anil ) ; whosThis ( alex ) ; return 0 ; }

Github.com/necolas/normalize.css Code Example

Example: normalize css npm install normalize.css

Can't Start A Program Because Qt5Cored.dll Is Missing

Answer : The file Qt5Cored.dll will exist on your system, otherwise it would not work from Qt Creator either. I think it's just Windows search that lets you down. Open a cmd prompt and do a dir c:\Qt5Cored.dll /s Another note is that those *d.dll are debug DLL's, which means you are distributing a debug version of your application. You might want to build a release version for distribution instead. (In which case you'll need Qt5Core.dll ) On my computer the Qt5Core.dll and other .dll files are stored here C:\Qt\Qt5.9.1\5.9.1\xxx\bin (where xxx is the compiler version). Your Qt version may differ. Copy the .dll files you want to the application location (where your .exe file is). These are the minimum .dll files I needed to copy for my basic app to work: libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll Qt5Core.dll Qt5Gui.dll Qt5Widgets.dll

Converting Angular Velocity To Quaternion In OpenCV

Answer : If I understand properly you want to pass from this Axis Angle form to a quaternion. As shown in the link, first you need to calculate the module of the angular velocity (multiplied by delta(t) between frames), and then apply the formulas. A sample function for this would be // w is equal to angular_velocity*time_between_frames void quatFromAngularVelocity(Mat& qwt, const Mat& w) { const float x = w.at<float>(0); const float y = w.at<float>(1); const float z = w.at<float>(2); const float angle = sqrt(x*x + y*y + z*z); // module of angular velocity if (angle > 0.0) // the formulas from the link { qwt.at<float>(0) = x*sin(angle/2.0f)/angle; qwt.at<float>(1) = y*sin(angle/2.0f)/angle; qwt.at<float>(2) = z*sin(angle/2.0f)/angle; qwt.at<float>(3) = cos(angle/2.0f); } else // to avoid illegal expressions { qwt.at<float>(0) = qwt.at<float>(0)

13cm In Inches Code Example

Example: cm to inch 1 cm = 0.3937 inch

9 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

Align Div Vertically Center Bootstrap 4 Code Example

Example 1: bootstrap center align columns < ! -- Center columns in a Row -- > < div class = "row d-flex justify-content-center text-center" > < div class = "col-4" > // Add Content < / div > < div class = "col-4" > // Add Content < / div > < div class = "col-4" > // Add Content < / div > < / div > Example 2: html center image vertically bootstrap mx - auto mt - auto mb - auto Example 3: bootstrap div vertical center < div class = "jumbotron d-flex align-items-center min-vh-100" > < div class = "container text-center" > I am centered vertically < / div > < / div > Example 4: how to center vertically in bootstrap col < div class = "my-auto" > . . . inner divs and content . . . < / div >

Sqr Root In Python Code Example

Example 1: python square root import math a = input ( "what do you wnat to square root" ) print ( math. sqrt ( a ) ) Example 2: python get square root import math toSquare = 300 squared = math. sqrt ( toSquare )

Sizeof String C++ Code Example

Example 1: c++ string size // C++ string size str . length ( ) ; str . size ( ) ; // synonym Example 2: create a string of length c++ # include <string> # include <iostream> int main ( ) { std :: string s ( 21 , '*' ) ; std :: cout << s << std :: endl ; return 0 ; } Example 3: c++ string size // string::size # include <iostream> # include <string> int main ( ) { std :: string str ( "Test string" ) ; std :: cout << "The size of str is " << str . size ( ) << " bytes.\n" ; return 0 ; }