Skip to content

Instantly share code, notes, and snippets.

View sukhmeet2390's full-sized avatar
🎯
Focusing

Sukhmeet Singh sukhmeet2390

🎯
Focusing
View GitHub Profile
@sukhmeet2390
sukhmeet2390 / GUIDE.md
Last active August 21, 2023 17:18
How to get all Jetbrains products for FREE! | Working (2022) | Full Guide
@sukhmeet2390
sukhmeet2390 / index.php
Created April 10, 2018 15:58
List all the files of a folder index.php
<?php
$path = ".";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != ".." && $file != "index.php" && $file != ".htaccess" && $file != "error_log" && $file != "cgi-bin") {
echo "<a href='$path/$file'>$file</a><br /><br />";
$i++;
}
}
// Loggable class
class Loggable extends React.Component {
logClick() {
console.log(`Element ${this.props.id} clicked`); $.post(`/clicks/${this.props.id}`);
}
}
// Extend it in ES6 version as there is no mixin
class Link extends Loggable {
handleClick(e) {
// Type 1
var ClickableImage = function(props) {
return (
<a href={props.href}> <img src={props.src} />
</a> );
};
// ES6 version
var ClickableImage = props => (
<a href={props.href}>
/* Module pattern
- Helps in both scoping private and public scoping
- Avoids global namespace
- Con: Privates are not easily testable
*/
var myModule = (function (){
var private1;
return {
attr1 : attr1,
const func1 = (x, y) // SyntaxError
=> {
return x + y;
};
const func2 = (x, y) => // OK
{
return x + y;
};
const func3 = (x, y) => { // OK
return x + y;
var player = {
name : 'Dhoni',
tasks : ['batsman', 'wicket-keeper','fielder'],
printTasks: function(){
this.tasks.forEach((task)=>{
console.log(this.name +' is a ' + task);
});
}
};
@sukhmeet2390
sukhmeet2390 / arrow-function-ES5_this.js
Last active August 2, 2016 17:58
Fixing this in ES5
// ES5 way
var player = {
name : 'Dhoni',
tasks : ['batsman', 'wicket-keeper','fielder'],
printTasks: function(){
this.tasks.forEach(function(task){
console.log(this.name +' is a ' + task);
});
}
};
@sukhmeet2390
sukhmeet2390 / arrow-function-ES6.js
Created August 2, 2016 15:33
Arrow function examples
// ES5 way
var square = function(x){
return (x*x);
}
// ES6 way
var square = (x) => { return x*x };
// if expression has only 1 line we can even drop the braces
var square = x => x*x;
* https://www.digitalocean.com/community/tutorials/an-introduction-to-securing-your-linux-vps
* https://help.ubuntu.com/community/UFW
* https://www.digitalocean.com/community/tutorials/how-to-use-psad-to-detect-network-intrusion-attempts-on-an-ubuntu-vps