Skip to content

Instantly share code, notes, and snippets.

View sandeepthukral's full-sized avatar

Sandeep Thukral sandeepthukral

View GitHub Profile
@sandeepthukral
sandeepthukral / add-data-test-to-angular.md
Created January 25, 2022 09:11
Adding test attributes to angular HTML code

For adding data-test atributes to regular HTML tags

If the data is hard coded <th data-test="foo">

If the value has code <th [attr.data-test]="'foo-' + data.bar" Here data is an object available to the code (as props) from which you extract the value of the key bar and add it to the static text foo-

@sandeepthukral
sandeepthukral / README.md
Created January 31, 2021 20:18
Extract Udemy course details

How to use

  • Open any udemy course page
  • Expacd all sections manually. To make life easy, start from the lowermost one. This will take maybe 30 seconds. Now that I think of it, this can also be automated
  • Paste the scrit in the console and execute. You will get the course section heads and details.
@sandeepthukral
sandeepthukral / cypress-tips-and-tricks.txt
Created September 28, 2020 14:23
Tips and Tricks for Cypress.io
Checking if a checkbox is checked
cy.get('input').then( $input => {
if ( $input.is(':checked') ) {
}
});
@sandeepthukral
sandeepthukral / bookmarklet-nl-wiktionary-vervoeging.js
Created December 17, 2019 09:07
Bookmarklet to open information page for any Dutch verb
javascript:
(function() {
var prefix = "https://nl.wiktionary.org/wiki/";
var suffix = "/vervoeging";
var woord = prompt("Welk woord zoek je informatie over?", "leggen");
if (woord != null) {
loc = prefix + woord.trim() + suffix;
location.href = loc;
}
}
@sandeepthukral
sandeepthukral / README.md
Created September 14, 2018 10:32
Count numbers on a webpage using Developer Console and JS. Change the selector on line 1 and , if required, the lastChild thing on the second.
@sandeepthukral
sandeepthukral / count-numbers.js
Created September 14, 2018 09:45
Count numbers on a webpage using Developer Console and JS
p = $('.btn.btn-pill')
s = 0; p.each((idx, e) => s += parseInt(e.lastChild.textContent.trim())); console.log(s)
@sandeepthukral
sandeepthukral / 0_reuse_code.js
Created March 18, 2017 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sandeepthukral
sandeepthukral / python_ignore_unicode_in_string.py
Last active December 17, 2019 09:17
python - remove annoying unicode characters
s = 'This is some \\u03c0 text that has to be cleaned\\u2026! it\\u0027s annoying!'
print(s.decode('unicode_escape').encode('ascii','ignore')) # This is some text that has to be cleaned! it's annoying!
@sandeepthukral
sandeepthukral / LICENSE
Last active August 29, 2015 14:27 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@sandeepthukral
sandeepthukral / gist:f3feed686656eedd5bf3
Last active August 29, 2015 14:22
Export HTML table to Excel in AngularJS

Export HTML table to Excel in AngularJS

myApp.factory('Excel',function($window){
		var uri='data:application/vnd.ms-excel;base64,',
			template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
			base64=function(s){return $window.btoa(unescape(encodeURIComponent(s)));},
			format=function(s,c){return s.replace(/{(\w+)}/g,function(m,p){return c[p];})};
		return {