Posts

Showing posts from May, 2011

Classes And Objects In Python Ppt Code Example

Example 1: classes and objects in python ppt class employee: pass #no attributes and methods emp_1=employee() emp_2=employee() #instance variable can be created manually emp_1.first='aayushi' emp_1.last='Johari' emp_1.email='aayushi@edureka.co' emp_1.pay=10000 emp_2.first='test' emp_2.last='abc' emp_2.email='test@company.com' emp_2.pay=10000 print(emp_1.email) print(emp_2.email) Example 2: classes and objects in python ppt class Class_name: statement-1 . . statement-N

As A Dev, Do You Use .gitignore To Ignore Everything And Purposefully Include? Or Do You Just Exclude With It?

Answer : The second method is the best practice, when it comes to exlude some folder contents of gitignore rules. It better reflect the following rule: It is not possible to re-include a file if a parent directory of that file is excluded. To exclude files (or all files) from a subfolder of an ignored folder f , you would do: f/** !f/**/ !f/a/sub/folder/someFile.txt Meaning: you need to whitelist folders first, before being able to exclude from gitignore files. It is clearer, shorter (unless you have a large number of folder to whitelist) What if it is a Joomla install with a large amount of directories and files? Or what if a core upgrade adds new files or folders Don't forget you can have multiple gitignore files, one per folder. That means you can mix and match both approaches. And you have: http://gitignore.io/ (which does blacklist when it comes to Joomla application) github/gitignore (same approach for Joomla)

Bypassing CAPTCHAs With Headless Chrome Using Puppeteer

Answer : Try generating random useragent using this npm package. This usually solves the user agent-based protection. In puppeteer pages can override browser user agent with page.setUserAgent var userAgent = require('user-agents'); ... await page.setUserAgent(userAgent.toString()) Additionally, you can add these two extra plugins, puppeteer-extra-plugin-recaptcha - Solves reCAPTCHAs automatically, using a single line of code: page.solveRecaptchas() NOTE: puppeteer-extra-plugin-recaptcha uses a paid service 2captcha puppeteer-extra-plugin-stealth - Applies various evasion techniques to make detection of headless puppeteer harder. Here is a list of things I'm doing to bypass the captchas and similar blockings: Enable stealth mode (via puppeteer-extra-plugin-stealth) Randomize User-agent or Set a valid one (via random-useragent) Randomize Viewport size Skip images/styles/fonts loading for better performance Pass "WebDriver check" Pass "Chrome c

Bootstrap Wysihtml5 Set Value Not Working

Answer : You should be able to achieve the same using below $("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5(); window.describeEditor = window.editor; And then later you should can use describeEditor.setValue(c.DescrizioneBreve, true) or use editorDescrizioneBreve.data("wysihtml5").editor.setValue(c.DescrizioneBreve, true); Where editorDescrizioneBreve is the object returned by $("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5() PS: Solution based on https://github.com/jhollingworth/bootstrap-wysihtml5/issues/52 For me, this worked: $('.wysihtml5-sandbox').contents().find('body').html(descr) I have only one Wysihtml5 on my page, with multiple, you need to use more precise selector.

Async Constructor Functions In TypeScript?

Answer : A constructor must return an instance of the class it 'constructs'. Therefore, it's not possible to return Promise<...> and await for it. You can: Make your public setup async . Do not call it from the constructor. Call it whenever you want to 'finalize' object construction. async function run() { let topic; debug("new TopicsModel"); try { topic = new TopicsModel(); await topic.setup(); } catch (err) { debug("err", err); } } Readiness design pattern Don't put the object in a promise, put a promise in the object. Readiness is a property of the object. So make it a property of the object. The awaitable initialise method described in the accepted answer has a serious limitation. Using await means only one block of code can wait on the action. This is fine for code with guaranteed linear execution but in multi-threaded or event driven code it's unte

Block Comment Matlab Code Example

Example 1: block of comments in matlab %{ Commented code here. %} Example 2: matlab comments % single line comment % Example 3: matlab comment % This is a one-line comment %{ This is a multi-line comment %}

Bash: Mongo: Command Not Found

Answer : The problem can solve if you add MongoDB path in the system variables: Go to this path " Control Panel\System and Security\System " on the left you should see some options click on " Advanced system settings " after this click on " Environment Variables " at the System variables should be one option " Path " click that option and " Edit " it, add " New " variable on this system, in my case, is " C:\Program Files\MongoDB\Server\4.2\bin " and save this change. if you're using git bash, use the following command $ ./mongo I've just had the same problem and did this to solve it. I hope it helps (late, but to be sure it is answered). Open GitBash and type the following: 1) cd.. // to go to the root directory. 2) touch .bash_profile // creates a hidden file to set up the shortcut 3) notepad .bash_profile // this opens that hidden file with notepad. You can also do it with VIM if you want t

Automatic Colors Assignment In Chart.js 2.x Doesn't Work Anymore, Used To Work In V. 1.x

Answer : I believe that creation of color schemes is a whole science of its own. It makes sense to me that something like that has been left out of Chart.js, since there are more critical goals to pursue. All colors used in chart examples in the docs are defined explicitly. And this two-month-old issue features a categorical response from a Chart.js member that default colors are not available in Chart.js 2. So, you have three choices. The first choice is to make some colors yourself. I guess you would not have asked the question, had you been into something like that (I know that the results would be horrible, if I did something like that). The second choice is to look for color schemes and color scheme generators online and pick some color schemes that please you. The third and interesting choice is to look for a JavaScript library that can produce color schemes at will. There are a couple of alternative choices. A nice one, which is available under very permissive lic

How To Scanf Char Array In C Code Example

Example 1: how to print char array in c char a_static [ ] = { 'q' , 'w' , 'e' , 'r' , '\0' } ; char b_static [ ] = { 'a' , 's' , 'd' , 'f' , '\0' } ; printf ( "value of a_static: %s\n" , a_static ) ; printf ( "value of b_static: %s\n" , b_static ) ; return 0 ; Example 2: return char array in c char * createStr ( ) { char char1 = 'm' ; char char2 = 'y' ; char * str = malloc ( 3 ) ; str [ 0 ] = char1 ; str [ 1 ] = char2 ; str [ 2 ] = '\0' ; return str ; }

Bash Script Check Argument Count Code Example

Example 1: bash parameter count # use $# # say if you are expecting exactly 2 parameters # -ne is bash's way of saying not equal if [ [ " $# " -ne 2 ] ] ; then echo "this script needs exactly 2 parameters" exit 1 fi Example 2: bash count number of arguments The number of arguments is $#

Alphabetizing Methods In Visual Studio

Answer : While Resharper has many cool features it has a large impact in CPU and I/O usage and can be very complicated to use. It is also only available under commercial licensing unless you qualify for a few very specific free use licenses. Try CodeMaid. It is free for commercial use and has a much lower performance overhead. I find it easy to use and it is very good for alphabetizing methods. To sort your file, open the file via solution explorer: Right click the open file Code Maid menu (likely near the top of the right click menu) Click Reorganize Active Document Alternatively, using the default CodeMaid hotkeys CTRL + M , Z to sort your active file. Resharper has a Type Members Layout, which can order members by type, accessibility and alphabetically as well. You can also take a look into Ora , which presents a pane in visual studio that is ordered (even though your source may not be). Link's dead. The following answer goes much further than the OP asks,

Can I Get A Phone Number By User Id Via Telegram Bot API?

Answer : No, unfortunately Telegram Bot API doesn't return phone number. You should either use Telegram API methods instead or ask it explicitly from the user. You cannot get "friends" of a user as well. You will definitely retrieve the following information: userid first_name content (whatever it is: text, photo, etc.) date (unixtime) chat_id If user configured it, you will also get last_name and username . It's possible with bots 2.0 check out bot api docs. https://core.telegram.org/bots/2-0-intro#locations-and-numbers https://core.telegram.org/bots/api#keyboardbutton

Printf Unsigned Long Code Example

Example: printf long long int % lld // Signed % llu // Unsigned

Haskell Not Equal Operator Code Example

Example: not equal sign haskel --Not equal Prelude> 4 / = 5 True

Bind Jump Mouse Wheel Up Csgo Code Example

Example 1: csgo mouse wheel jump bind bind mwheelup + jump ; bind mwheeldown + jump ; bind space + jump Example 2: bind mousewheel jump csgo bind "mwheelup" "+jump" ; bind "mwheeldown" "+jump" ;

Appcenter Login Code Example

Example: appcenter login appcenter login

Array Length Php Code Example

Example 1: php string length <?php $str = 'abcdef' ; echo strlen ( $str ) ; // 6 $str = ' ab cd ' ; echo strlen ( $str ) ; // 7 ?> Example 2: php array length count ( $myArray ) ; Example 3: php length of array <?php $arr = [ "one" , "two" , "three" , "four" ] ; echo count ( $arr ) ; ?> Example 4: php array lenght <?php $cars = array ( "Volvo" , "BMW" , "Toyota" ) ; echo count ( $cars ) ; ?> Example 5: get array length using php // using count() we can get proper length of the array $names = array ( "Ankur" , "Raj" , "Ram" , "Suresh" ) ; // pass array into count() as parameter it will return array length echo count ( $names ) ; // output : 4 Example 6: array length php // https://www.php.net/manual/en/function.count.php $a = array ( 1 , 3 , 5 ) ; echo count ( $a ) ; // -> 3