Skip to content

Instantly share code, notes, and snippets.

View petersirka's full-sized avatar
🤓
From zero to hero

Peter Širka petersirka

🤓
From zero to hero
View GitHub Profile
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active April 24, 2024 12:51
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@arlg
arlg / Good Javascript
Last active October 15, 2018 10:37
Javascript the good way
/*FOR LOOPS
-------------------------------------------*/
//SLOW -> (no caching of the length)
for (var i = 0; i < myArray.length; i++) {}
//GOOD -> (caching the length) : http://jsperf.com/forloops3
for (var i = 0, l = myArray.length; i < l; i++) {}
//BEST -> backwards for loop + caching the length : http://jsperf.com/forward-and-backward-for-loops/2
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active May 2, 2024 01:27
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r